DBXML 2.4.16:  Accessing containers from multiple threads and deadlock

Hi,
I am evaluating dbxml for my upcoming project (http://xcapserver.sourceforge.net) where I am sending following four requests through multiples threads which gets into deadlock situation after running certain iterations. Can you please help me what am I doing wrong?
1. Put Document
2. Get Document
3. Get Document Node (XPATH Query)
4. Delete Document
I am using following environment variables.
u_int32_t env_flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |DB_INIT_TXN | DB_THREAD|DB_RECOVER| DB_AUTO_COMMIT; (I tried removing DB_AUTO_COMMIT)
dbEnv_.open(dbxml_env.c_str(), env_flags, 0);
XmlManager instance is initialized as :pxmlmgr_= new XmlManager(&dbEnv_) ;
pxmlmgr_->setDefaultContainerType(DbXml::XmlContainer::WholedocContainer);
NOTE: pxmlmgr_ instance is member variable of singleton class assuming XmlManager is thread safe and can be reused for all threads.
Below is the psudo code. It is written in C++. I have removed exception handling and other code for clarity.
getDocument (...){
XmlTransaction containerTxn =pxmlmgr_->createTransaction();
          XmlContainer cont = pxmlmgr_->openContainer(container, DB_RDONLY|DB_THREAD);
          XmlDocument doc = cont.getDocument(document);
          containerTxn.commit();
          data = doc.getContent(data
NOTE: To use doc(...) function, I have to create an alias than only I can use container name e.g /dbxml/resource-lists/users/rjoshi where /dbxml is env_home.
container name: /dbxml/resource-lists/users/rjoshi (here rjoshi is container name)
document name: presence
getDocumentNode(...) {
size_t npos = container.find_last_of("/", container.length());
          std::string alias = container.substr(npos+1, container.length()-npos) + "_" + document;
               XCAP_DEBUG("Alias:" + alias);
               std::string fullQuery = "doc('dbxml:" + alias + '/' + document + "')" + node;
               XCAP_DEBUG("XPath Full Query:" + fullQuery);
               XmlTransaction txn = pxmlmgr_->createTransaction();
               XmlContainer cont = pxmlmgr_->openContainer(container, DB_RDONLY|DB_THREAD);
               cont.addAlias(alias);
               //query context
               XmlQueryContext context = pxmlmgr_->createQueryContext();
          XmlResults results(pxmlmgr_->query(fullQuery, context ) );
               cont.removeAlias(alias);
               txn.commit();
putDocument(....){
size_t npos = container.find_last_of("/", container.length());
          std::string dir = container.substr(0, npos);
               boost::filesystem::path p(dir);
               if(!boost::filesystem::exists(p)) {
                    boost::filesystem::create_directories(p);
               XmlTransaction txn = pxmlmgr_->createTransaction();
               XmlContainer cont = pxmlmgr_->openContainer(container, DBXML_TRANSACTIONAL|DB_THREAD|DB_CREATE);
          XmlUpdateContext updateContext = pxmlmgr_->createUpdateContext();
               cont.putDocument(document, data, updateContext, 0);
               txn.commit();
deleteDocument() {
XmlTransaction txn = pxmlmgr_->createTransaction();
          XmlContainer cont = pxmlmgr_->openContainer(container, DB_THREAD);
          XmlUpdateContext updateContext = pxmlmgr_->createUpdateContext();
          cont.deleteDocument(document, updateContext);          
          txn.commit();
}

1. What platform are you on?
rjoshi>>I am running on mac OSX 10.5.8
2. There are still some potential coding issues here:
2a. In DbXmlDb.hpp there is a DbEnv instance which is
a member of your class. If using DbEnv as a data member
it is usually best to use new/delete vs making it a member.
rjoshi>>I have modified code to use new/delete
2b. In DbXmlDB.cpp DBXML_ADOPT_DBENV is being used.
DBXML_ADOPT_DBENV requires that DbEnv be created via
new() as it calls delete() on it.
rjoshi>> modified code to use new/delete
2c. In general is it best not to open containers upon
each use. Containers should be opened and shared among
threads.
rjoshi>> In real application, multiple devices (e.g IM, Phone) can read/write same document but it's not always the case so I don't want to open the container and keep in the memory. There is no way for me to know when to close the container. Is there any way to set flag where container can be open for certain duration and if not used, it will get closed and removed from memory?
2d. Instead of using a transaction for opening containers
use DBXML_TRANSACTIONAL|DB_THREAD. Also the use of
DB_RDONLY in the read cases will not change anything significant
as open instances are shared and the state of the first
one is the only one that counts.
rjoshi>> In init() function, I am setting default container flags as
pxmlmgr_->setDefaultContainerFlags(DB_CREATE | DB_THREAD
               | DBXML_TRANSACTIONAL);
Do I still need to set these flags while opening the container?
2e. The setting of DB_THREAD looks to be used inconsistently.
It should be used all the time if the application is
making use of threading.
rjoshi>> Again I was setting default flag for container as below in the init() function so was not using it. I have corrected the inconsistency.
pxmlmgr_->setDefaultContainerFlags(DB_CREATE | DB_THREAD
               | DBXML_TRANSACTIONAL);
2f. I can not tell for sure from looking at the cpp file,but
just make sure that operation-based transactions are consistently
passed in the application.
rjoshi>> I have removed transactions while opening the container and using all other places.
Still I am able to reproduce the deadlock. Please see the below output of db_state -CA.
bash-3.2$ ./db_stat -h /dbxml/ENV -CA
Default locking region information:
3327     Last allocated locker ID
0x7fffffff     Current maximum unused locker ID
9     Number of lock modes
1000     Maximum number of locks possible
1000     Maximum number of lockers possible
1000     Maximum number of lock objects possible
39     Number of current locks
143     Maximum number of locks at any one time
75     Number of current lockers
313     Maximum number of lockers at any one time
12     Number of current lock objects
26     Maximum number of lock objects at any one time
6643     Total number of locks requested
6560     Total number of locks released
0     Total number of locks upgraded
2166     Total number of locks downgraded
531     Lock requests not available due to conflicts, for which we waited
9     Lock requests not available due to conflicts, for which we did not wait
0     Number of deadlocks
0     Lock timeout value
0     Number of locks that have timed out
0     Transaction timeout value
0     Number of transactions that have timed out
464KB     The size of the lock region
60     The number of region locks that required waiting (0%)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lock REGINFO information:
Lock     Region type
7     Region ID
/dbxml/ENV/__db.007     Region name
0xf000     Original region address
0xf000     Region address
0xf044     Region primary address
0     Region maximum allocation
0     Region allocated
Region allocations: 3005 allocations, 0 failures, 0 frees, 1 longest
REGION_JOIN_OK     Region flags
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lock region parameters:
786457     Lock region region mutex [60/23741 0% 12394/0]
1031     locker table size
1031     object table size
436     obj_off
45860     locker_off
1     need_dd
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lock conflict matrix:
0     0     0     0     0     0     0     0     0     
0     0     1     0     1     0     1     0     1     
0     1     1     1     1     1     1     1     1     
0     0     0     0     0     0     0     0     0     
0     1     1     0     0     0     0     1     1     
0     0     1     0     0     0     0     0     1     
0     1     1     0     0     0     0     1     1     
0     0     1     0     1     0     1     0     0     
0     1     1     0     1     1     1     0     1     
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Locks grouped by lockers:
Locker Mode Count Status ----------------- Object ---------------
c3e dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c3e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
c41 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c42 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c42 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
c45 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c46 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c46 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
c49 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c4a dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c4a READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
c4d dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c4e dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c4e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
c51 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c52 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
c52 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
c52 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
c55 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c59 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c59 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
c5c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c5d dd= 0 locks held 2 write locks 0 pid/thread 12389/0
c5d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
c5d READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
c60 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000325 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000326 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
80000326 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
80000326 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
80000327 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c8e dd= 0 locks held 2 write locks 0 pid/thread 12389/0
c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
80000328 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
80000328 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
80000328 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
8000032a dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c91 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032b dd= 0 locks held 3 write locks 1 pid/thread 12389/0
8000032b WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
8000032b READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
8000032b WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
8000032b READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
8000032c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032c READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
c93 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032d dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c94 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032e dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032e READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
c95 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
8000032f dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000330 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000330 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000331 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000332 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000332 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
c99 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c99 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
80000333 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000333 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000334 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000334 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000335 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
c9c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000336 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
80000336 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
c9d dd= 0 locks held 1 write locks 0 pid/thread 12389/0
c9d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
ca0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
ca1 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
ca1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
ca4 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
ca5 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
ca5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
ca8 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
ca9 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
ca9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
cac dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cad dd= 0 locks held 2 write locks 0 pid/thread 12389/0
cad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
cad READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
cb0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cb4 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
cb4 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
cb7 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cb8 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
cb8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
cb8 READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
cbb dd= 0 locks held 0 write locks 0 pid/thread 12389/0
ce9 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
cec dd= 0 locks held 0 write locks 0 pid/thread 12389/0
ced dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cee dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cef dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf1 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf2 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf3 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf4 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf5 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf6 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf7 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf8 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cf9 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cfa dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cfb dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cfc dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cfd dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cfe dd= 0 locks held 0 write locks 0 pid/thread 12389/0
cff dd= 0 locks held 0 write locks 0 pid/thread 12389/0
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Locks grouped by object:
Locker Mode Count Status ----------------- Object ---------------
80000326 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
80000328 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
8000032b READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
8000032b WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
8000032c READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
8000032e READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000330 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000332 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000333 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000334 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
80000336 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
c4e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
ca9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
c4a READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
ca5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
c59 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
cb4 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
8000032b WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
8000032b READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
80000328 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
80000326 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
c52 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
cad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
c3e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
c99 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
c52 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
c5d READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
cad READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
cb8 READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
c46 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
ca1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
c42 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
c9d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
c5d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
cb8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16

Similar Messages

  • Can I access music from multiple accounts on one cpu?

    Can I access music from multiple accounts on one cpu

    Here's one option: http://support.apple.com/kb/PH12366
    But frankly you'd be better off creating unique user accounts on the computer and having seperate iTunes libraries for each user as described here: http://support.apple.com/kb/ht1495

  • POWL accessing data from multiple tables/objects

    Hello,
    I have a query on the POWL applications.
    If the powl application has to access data from multiple tables/objects, then the solution would be creating a data structure of those tables/objects and referring to that structure in GET_OBJECT_DEF methods.
    Is there any other soln? or I am right here?
    The queries which are saved for a particular user are transportable? if not, how can they be made transportable?
    Thanks & regards,
    Ravish

    you are right, you can do in get_objects method.
    POWL_QUERIES are transportab;e, you can save them in POWL_QUERY transaction.
    Best regards,
    Rohit
    http://wiki.sdn.sap.com/wiki/display/WDABAP/POWL

  • Synchronize work from multiple threads using wait() and notifyAll() help

    Hello folks,
    (Sorry for my bad english)
    My current project handles multiple access requests to a shared collection from multiple threads originating from different classess and methods. Therefor I need to keep track of the order in which the Threads access that collection. I wrote a sort of Buffer class that has a static instance entry which initiate a new Instance of my Buffer class, attributes the instance a cue number and return the instance to the caller Thread.(Just like when you go to a supermarket and draw a number to wait to get served at the cheese counter).The callerThread then uses this instance to execute a method within the buffer class. Inside the buffer class method, I want to set a while loop on wait() just like this:
    while(currentCue != myCueState)
    wait();
    when all other prior method calls within my Buffer class are done, the loop should wake up using a notifyAll() call and check the condition "currentCue != myCueState" agen to see if its turn has come.
    I am new to the wait() and notifyAll() stuff and are therefor not sure what I am dooing wrong here: The only way this buffer class finishes all it's cues is when the caller Threads are beeing executed in the same order than they have checked in to the Buffer class. Otherwise I get some sort of dead-lock in the middle. Here is my code for the Buffer class:
    public class Buffer{
        private static int currentCue = 0;
        private static int lastCued = 0;
        private int myCueState;
        private Buffer myInstance = null;
        synchronized void doTaskOne(){      
            try{
                while(currentCue != myCueState)
                    wait();           
                //Do your task now
                System.out.println("doTaskOne got Executed: "+currentCue);
                currentCue++;
                notifyAll();
            catch(Exception a){}
        synchronized void doTaskTwo(){
             try{
                while(currentCue != myCueState)
                    wait();
                //Do your task now
                System.out.println("doTaskTwo got Executed: "+currentCue);
                currentCue++;
                notifyAll();
            catch(Exception a){}
        synchronized void doTaskThree(){
            try{
                while(currentCue != myCueState)
                    wait();          
                //Do your task now
                System.out.println("doTaskThree got Executed: "+currentCue);
                currentCue++; 
                notifyAll();
            catch(Exception a){}
        synchronized Object getSomething(){
            try{                   
                while(currentCue != myCueState)
                    wait();           
                //Do your task now
                System.out.println("getSomething got Executed");
                currentCue++;
                notifyAll();
            catch(Exception a){}
            return "something";
        //Access the buffer class through a single static synchronized instance and draw a turn number
        public synchronized Buffer instance(){
            myInstance = new Buffer();
            myInstance.setMyCueState();
            return myInstance;
        private void setMyCueState(){
             myCueState = lastCued;
             lastCued++;
    }and here for the Test class I have coded to test this:
    public class TestBuffer{
         private Buffer accessOne;
         private Buffer accessTwo;
         private Buffer accessThree;
         private Buffer accessFour;
         public TestBuffer(){
                    //Instantiate different instances from Bufferclass and draw a number
              accessThree = new Buffer().instance();
              accessOne = new Buffer().instance();
              accessTwo = new Buffer().instance();          
              accessFour = new Buffer().instance();
              Thread one = new Thread(){
                   public void run(){
                        accessOne.doTaskOne();
              Thread two = new Thread(){
                   public void run(){
                        accessTwo.doTaskTwo();
              Thread three = new Thread(){
                   public void run(){
                        accessThree.doTaskThree();
              Thread four = new Thread(){
                   public void run(){
                        accessFour.getSomething();
              try{               
                   one.start();                    
                   two.start();
                   three.start();     
                   four.start();                         
              catch(Exception f){}
         public static void main(String args[]){
              TestBuffer myTest = new TestBuffer();
    }What am I doing wrong here??
    Maby this is not how I should use the notifyAll() method, but how then?
    Please give me a solution!
    Thanks

    Ok, so if I get you guys right, the following should do it:
    public class Buffer{
        private static Object sharedLock = new Object();
        public void doTaskOne(){      
              synchronized(sharedLock)  {
                System.out.println("doTaskOne got Executed: ");
        public void doTaskTwo(){
             synchronized(sharedLock)  {
                System.out.println("doTaskTwo got Executed: ");
        public void doTaskThree(){
             synchronized(sharedLock)  {
                  System.out.println("doTaskThree got Executed: ");
        public Object getSomething(){
            synchronized(sharedLock)  {
                System.out.println("getSomething got Executed");
                return "something";
    }Lets say that each method accesses the same ressources (in this case a table model) to retreave values, delete rows and set some existing values vith new values and all this 20-30 times a minute, all processing will stay synchronised and collision is not possible?
    And lets say I would update the Table model directly from the buffer Class using MyTableModel.instance().setValueAt() or watever methods I implemented on my Table model, could I safely do that using "SwingUtilities.invokeLater();" from my BufferClass just like this:
    public void doTaskThree(){
            synchronized(sharedLock)  {
                   Runnable runme = new Runnable(){
                         public void run(){
                                MyTableModel.instance().setValueAt("abc", 5,5);  
                   SwingUtilities.invokeLater(runme);
    }Thanks in advance for your help guys!

  • I am accessing iCloud from my Mac and want to know where I find my iMessages in my Mac.  Thank you!

    I am accessing iCloud from my Mac and want to know where to find my iMessages within iCloud.  Can anyone help me out with this?  Thank you so much!

    Welcome to the Apple Community.
    Applications > messages (assuming you are using Mountain Lion)

  • Process to get info from Multiple textboxes and check boxes on a page

    Hi,
    Could you help me with setting up a process which selects the data from multiple textboxes and checkboxes on a page and should be pointing to a single table in the database.
    Thanks in advance,
    Verity.

    Thanks Peter for the reply,
    Actually the problem is, there are lot of check boxes. And process should be like when a user clicks on, say 7 out of 10 checkboxes, only those values needs to be inserted in a table in database. Actually my "insert all" statement is inserting 7 values and also the other three values as null. I tried insert with 'when' and 'if' but didnt get through. my sample insert statement is as follows. Could you help me here.
    DECLARE
    BEGIN
    insert all
    when (:P1_POT='PT') then
    into TABLENAME
    (oid,year, code)
    values
    (:F1_ID, :F1_YEAR, :P1_HR)
    when (:P1_HOL='SC')
    then into TABLENAME
    (OID, year,code)
    values
    (:F1_ID, :F1_YEAR, :P1_SD)
    select oid,year,code from TABLENAME;
    END;

  • Retrieve Title field values from multiple lists and add into another list

    Hi , Iam trying to retrieve Title field value from multiple lists. and add them into another list. using Javascript. Can any one help me in doing this. Below is the code.. function save() { clientContext = new SP.ClientContext.get_current(); oWebsite = clientContext.get_web(); oList = clientContext.get_web().get_lists().getByTitle('MainList'); clientContext.load(oList); clientContext.executeQueryAsync(OnSucceeded, onQueryFailed); } function GetListItemValue(listName, fieldName) { var list = oWebsite.get_lists().getByTitle(listName); var eventValue = document.getElementById(fieldName).value; eventValue = eventValue.replace(",", ""); var camlQuery = new SP.CamlQuery(); var filterdata = '<view><query><where><eq><fieldref name="Title/"><value type="Text">' + myreqValue.trim() + '</value></fieldref></eq></where></query></view>'; camlQuery.set_viewXml(filterdata); listItems = list.getItems(camlQuery); clientContext.load(list); clientContext.load(listItems, 'Include(Id)'); clientContext.executeQueryAsync(Succeeded,Failed); } function OnSucceeded() { itemCreateInfo = new SP.ListItemCreationInformation(); oListItem = oList.addItem(itemCreateInfo); oListItem.set_item('Title', 'My New Title'); var deptItemLookupField = new SP.FieldLookupValue(); //Problem in below line...I was unable to get ID var getId = GetListItemValue("Listname1", "txtboxname1"); alert("ID" + getId); if (getId != undefined) { deptItemLookupField.set_lookupId(getId); } var getId12 = GetListItemValue("Listname12", "txtboxname12"); alert("ID" + getId12); if (getId12 != undefined) { deptItemLookupField.set_lookupId(getId12); } oListItem.update(); clientContext.executeQueryAsync(itemadded, itemFailed); } function itemadded() { alert('Item added successfully'); } function itemFailed(sender, args) { alert('Item added itemFailed' + args.get_message() + '\n' + args.get_stackTrace()); }
    Raj

    Hi,
    For this requirement, you will need to retrieve all the lists objects you want firstly, then execute the requests one by one to get the value of the Title column using CAML or
    LINQ.
    How to: Retrieve Lists Using JavaScript
    http://msdn.microsoft.com/en-us/library/office/hh185009(v=office.14).aspx
    About
    retrieve list items:
    http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
    You can use
    Promise in your script to make your requests sequentially:
    http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx
    http://www.learningsharepoint.com/2013/08/13/using-deferred-and-promise-to-handle-async-calls-in-sharepoint-client-object-model/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Calling System.exit() from multiple threads

    Hi,
    Why would calling System.exit() from multiple threads cause all the threads to block?
    Laith

    Thanks for your replies.
    I made further tests and the problem is actually not as I described it first.
    I'm using a shutdown hook that would stop all running threads if the program is stopped externally (using ctl-c for example) (I'm not using Thread.stop(), but setting a boolean value to false that would make the thread exit a while() loop in run()) .
    One of the running threads would call System.exit(-1) just before it would exit run().
    This thread is getting blocked if it is stopped by the shutdown hook.
    I know that this is a bad coding practice, bout would still appreciate an explanation to the reason why the thread is actually blocked by System.exit().
    Laith

  • Diff between Multiple Threading and Multiple instance.

    Hi ,
    what is the main diff between Multiple Threading and Multiple instance?
    Please give me the answer

    Satti4Java wrote:
    Hi ,
    what is the main diff between Multiple Threading and Multiple instance?The main difference (not "diff") is that the first one ends with the word "Threading" and the second one ends with the word "instance".
    Really. Seriously. Now if you had some industry standard phrases you were comparing, there might be a useful discussion. But those are just words strung together. If that's a homework question, I recommend you find a different teacher.

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • Dbms_xmlgen.newcontext query from multiple tables and ||

    I have two questions
    How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
    And how to get the || (concat) to work within my query for my output to an xml file?
    Here is my current query:
    create or replace function get_xml return clob is
    result clob;
    qryctx dbms_xmlgen.ctxHandle;
    SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
    FROM rcv.recv_accessions ra
    where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
    result := DBMS_XMLGEN.getXML(qryCtx);
    This is what I desire:
    SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
    FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
    where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
    On this both the reference to multiple tables and the concat function cause errors.
    Thank you
    Edited by: user583094 on Mar 2, 2011 3:36 PM

    Hi,
    for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
    The || operator will do fine, but you must escape any single quote inside the string :
    SELECT DBMS_XMLGEN.getxml(
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id'
    INTO result
    FROM dual;Or, use the quoting operator to define a custom string delimiter :
    SELECT DBMS_XMLGEN.getxml(
    q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id
    INTO result
    FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
    CREATE OR REPLACE FUNCTION get_xml
    RETURN CLOB
    IS
    qryctx   DBMS_XMLGEN.ctxHandle;
    v_out    CLOB;
    qrystr   VARCHAR2(4000) :=
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = :b_prefix
    AND ra.fiscal_yr = :b_fiscal_yr
    AND ss.raid = ra.id
    AND st.ssid = ss.id';
    BEGIN
    qryctx := DBMS_XMLGEN.newContext(qrystr);
    DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
    DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
    -- to generate empty elements if necessary :
    DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
    v_out := DBMS_XMLGEN.getXML(qryctx);
    DBMS_XMLGEN.closeContext(qryctx);
    RETURN v_out;
    END;

  • ALV for fields from multiple tables and make them editable

    Hi,
    I am working on a forecasting report. We have created few custom table e.g. store forcaset detail for whole year month wise. tables are say sales data, budget data, forcast data etc.
    Now i need to make a report based on monthwise based on above mention table.
    eg.o/p looks like:
    column name                     type desc monthapr monthmay .......
    table forcast                      Qty  sales    100          150
    table budget/sales             amt   amou    20.50    130.50
    table sales vs forcast       amt   amount  3000     50000
    -Now i don't know how to display data from multiple table in single ALV list that to with different field type.
    -2nd issue is i need to make only perticuler row editable so that user can chage data.
    -3rd when user change data and press calulate button - it should calculate data for future month - i got formula for that and disply the calulated data.
    - 4th if user like the forcast data then when press save - change data should update dbtable.
    Is this all possible with simple abap FM Or need to use ABAPOO.
    I will appericiate all expert help.
    Many thanks in advance.
    KDE.
    Edited by: kde_test on Jun 4, 2010 5:44 PM

    Hi,
    Solutions :
    1. You can use  FM REUSE_ALV_HIERSEQ_LIST_DISPLAY as guided by Ashutosh.
    You can also check out this
    [http://www.sap technical.com/Tutorials/ABAP/3DGraph/demo.htm]  change link to saptechnical without space
    2. [How to make certain rows in ALV grid editable...;
    3 & 4. Use two importing paramaters 'PF_STATUS_SET' 'USER_COMMAND' of  REUSE_ALV_GRID_DISPLAY.
    create two function codes 'CALC and 'SAVE' in pf-status and provide your required functionality to these function codes using User-Command.
    Sorry am unable to provide you with supporting code, but you can search for it and It can solve your problem
    Regards,
    Rohit

  • Are you suppose to access UIView from another thread?

    A lot of UI events in my apps take place in another thread. So in my uivewcontroller, it catches a button click for example, it launches a NSThread with some parameter. The reason I decided to use a thread is because if the duration takes long the UI completely locks up. The thread then fetches for some result and access a pointer to a UIView (a UILabel for example) and update it's content.
    Now, is this model correct? I'm running in cases where setting the UILabel.text from the thread sometimes work, sometimes doesnt. I'm not sure how to debug. If I change the thread call to a standard method call (which blocks until results are ready) the text is updated correctly.
    Any hints?

    http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadS afetySummary/chapter950_section2.html

  • Collecting Notifications from multiple servers and applications

    Hi,
    I'm researching JMX technology for our Enterprise-wide monitoring needs.
    I've got a good understanding of how to create jmx connections and instrument resources for monitoring in a 1-to-1 jmx client to application scenario.
    However, I need to manage (and collect notification alerts) from multiple servers/applications.
    Any ideas where to start learning how to do this?
    Thanks,
    Jon

    Hi Gavin,
    So, you're looking into JMX monitoring solutions too. great! I've collected some good links and examples.
    You can email me privately at jcolby550 "at" hotmail "dot" com, maybe we can share ideas.

  • Unable to use AirPlay from multiple iOS and MacBook pro

    HI, I seem to be having issues using AirPlay From multiple iOS devices.
    I have the following devices, iphone 6 plus, iPad air (both Gen 1 and 2) an iPad 2 and a MacBook Pro running Yosemit. I also have 2 Apple TVs (both gen 1 and 2).
    Recently I have found that I am unable to use AirPlay on any of the iOS devices to either Apple TVs, the MacBook Pro will Airplay mirror ok, I am however able to use iTunes shairing from a Windows 8PC. I have restarted and also reset both Apple TVs and my router, I have also reset the connection settings on all the iOS devices but still can't resolve the issue.
    The Apple TVs have Internet connection so I can't see any issues network connections.
    ANyone else got got any Ideas?
    Thanks

    Try the following steps, check whether things are working after each step where appropriate, before trying the next.
    Check AirPlay is turned on on the Apple TV (turn it off and on if it already is)
    Check that both devices are on the same network (Settings > Wifi, on the mobile device and Settings > General > Network, on the Apple TV).
    Restart the Apple TV (Settings > General > Restart).
    Restart the Apple TV by removing ALL the cables for 30 seconds.
    Restart your router. (Also try removing it’s power cord for at least 30 seconds)
    Restart your mobile device.
    If you are still having problems, the following article(s) may help you.
    Troubleshooting AirPlay
    Troubleshooting Wi-Fi networks and connections
    Recommended Wi-Fi settings
    Wifi Diagnostic Software (for Mac users)
    You may also find some help on this page, where I’ve collected some of the more unusual solutions to network issues.
    When making adjustments to your network for better optimisation, you may find some of the points mentioned on this page helpful.
    This is answer is provided from my own database of boilerplate responses and the content was last reviewed and/or tested on: 2014/12/16

Maybe you are looking for

  • Error while connecting to db

    Hi, We are getting the error while connecting the database. ERROR: ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist IBM AIX RISC System/6000 Error: 2: No such file or directory Error persists only for second or two & agai

  • I have a question about icloud.

    I do not have icloud in my system preferences.  I have mail set up on icloud and did the transfer of my mobile me account.  But icloud does not appear in the system preferences.  Where is it or is it not supposed to be there.  Mobile me is in the pre

  • External drive shows yellow

    I just attached a new external drive to my iMac.  I set it up to replace a drive I was using for backup.  I cleared off the old drive and want to use it to store/backup my photos.  It shows up as a yellow icon on my desktop and the other is green wit

  • How can i download hobbit 2 trailer in Ipad

    How can i download hobbit 2 trailer in Ipad as according to the question i put on.

  • Unable to launch X11 after 10.5.5 update

    Greetings, After updating to 10.5.5 yesterday, X11 refuses to launch. Maybe a font issue? The console message is as follows: 9/17/08 11:51:31 AM org.x.startx[3811] font_cache: Scanning user font directories to generate X11 font caches 9/17/08 11:51:3