Object blocking a thread

When a thread is blocked, it shows up in BLOCKED state in the console. How to check from the console the object on which this thread is blocked ?

Hi Erik,
The thread is shown as "Blocked". The "Lock" column shows the object on which the thread is blocked. But the columns "Lock Owner ID" and "Lock Owner Name" are displayed as N/A. I know that the thread that is holding the lock is live. When a thread is waiting for a lock, and the lock is known, shouldn't there be a owner for the lock? Then why are these columns being displayed as "N/A".

Similar Messages

  • Accessing Object using mutliple threads

    I created a class that creates 2 threads and both thread calls a method ( not synch..). In the method i create a new object.
    Here is the code for it.
    class ggh{
        public void m1(){
            ss s1= new ss();      // Simple class having 2 fields(int and string) and their getter setters
            System.out.println("S1 for thread #" + Thread.currentThread().getName() + "  ==> " + s1.toString()  );
            if(Thread.currentThread().getName().equals("Thread-0"))  // thread #1
                try {
                    Thread.sleep(1000);      // -------------> 1
                s1.setA(2);                           // --------------> 2
                System.out.println("Settin s1 = null " + Thread.currentThread().getName());
                    s1 = null;                         //  ---------------> 3
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
            System.out.println("s1 a==>" + s1.getA() + "::" + Thread.currentThread().getName() + " :: " + s1.toString());         //----------------> 4
        public static void main(String[] args) {
            final ggh g1 = new ggh();
            Thread t1 = new Thread(){
                public void run(){
                    g1.m1();
            Thread t2 = new Thread(){
               public void run(){
                        g1.m1();
            t1.start();
            t2.start();
    }when i execute this code, my output is totally unpredictable. Here are some of the outputs i got.
    ************** 1 The code creates the same object for both threads
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************** 2 objects are different now.
    S1 for thread #Thread-0 ==> vom.cdd.ss@f5da06
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************* 3 [Here nullpointer exception occurs before the null message is printed[/b]
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    Settin s1 = null Thread-0
    So my question here is :
    when such kind of unsynch. access occurs for some method. then does there exists a different object [b]( a new memory is allocated ) for each thread
    or does there exist only one object and each thread has a different reference to it, and the thread can manipulate its properties.
    Or does there exist a different explanation for this kind of behaviour??
    One more thing, i dont wnat the method/a block of code to be synchronized.
    I also have another doubt but willl post it after this one get's cleared.
    Thanks in advance.
    Regards
    Akshat Jain

    2 objects are different nowThey are not different at all. Address can differ at
    each invocation.What do u mean that they are not different at all.
    if they have different object's then obviously their address are different and henc the objects too.
    am i getting this wrong??

  • SSL connections blocking worker threads on DS 5.2 patch 4

    Hi,
    Is it normal for an idle SSL connection to consume a worker thread within the directory server?
    We have recently enabled SSL on a number of our directory servers (5.2 patch 4) and have run into problems with the server hanging. We have a number of application servers, each opening a pool of connections to the servers via JNDI. It seems that once 30 SSL connections have been established to a give LDAP server, the server will hang. By hang I mean the server is accepting TCP connections, but not responding to LDAP requests.
    The server can deal with a lot more than 30 non-ssl connections. I'm guessing that SSL connections need to maintain state, which is what is tying up the worker threads.
    Is this normal, and is it docuemented anywhere? Currently I'm looking at terminating the SSL connections on a load balancer in front of the LDAP servers, or perhaps on an LDAP proxy. Any other suggestions as to how this is typically dealt with?
    thanks,
    R

    Thank you Gautam.
    On further testing yesterday, we discovered that the problem is just as you have described. Our application servers are opening an initial pool of five connections, but typically only using one of those connections. The one connection the server uses to make an LDAP request behaves 'normally', not tying up a thread on the LDAP server. The other four sit there blocking a thread each, until eventually we hit the nsslapd-threadnumber.
    Based on that discovery, we're having the application changed so that its initial LDAP connection pool size is one, which appears to address the problem. That way connections are only established and added to the pool as they are required, resulting in well behaved connections to the LDAP server.
    Thanks for the quick reply... The Sunsolve note is helpful, as is the info about the nsslapd-ioblocktimeout parameter.
    kind regards,
    R

  • How to pass a "user defined" object to a thread?

    Hi...
    I have created an object say 'obj1' . I want to pass to a thread say 'T1' .
    The thread T1 implements the runnable class.
    I need to pass the "obj1" object to the T1 for it to be processed in the "run" method of T1.
    As far as I have seen there is no thread constructor in Java that accepts an object created by the user.
    My question is there any way to pass an object to a thread? and if so how can it be done?

    You can just add your own method to the class. Then call that method to pass the object to the thread before you call start on the thread.
    class MyThread implements Runnable
       public void run()
          userObj.whatever();
       public void addObj(Object obj)
          userObj = obj;
       Object userObj = null;
    // your code
    MyThread thread = new MyThread();
    thread.addObj(myObj);
    thread.start();As long as you don't call start before your pass the object to your thread, then you won't have a problem. Hope this helps.

  • Immutable Objects in multi threaded application - how does it works?

    Hi
    I have this code will work in multithreaded application.
    I know that immutable object is thread safe because its state cannot be changed. And if we have volatile reference, if is changed with e.g.
    MyImmutableObject state = MyImmutableObject.newInstance(oldState, newArgs); i.e. if a thread wants to update the state it must create new immutable object initializing it with the old state and some new state arguments) and this will be visible to all other threads.
    But the question is, if a thread2 starts long operation with the state, in the middle of which thread1 updates the state with new instance, what will happen? Thread2 will use reference to the old object state i.e. it will use inconsistent state? Or thread2 will see the change made by thread1 because the reference to state is volatile, and in this case thread1 can use in the first part of its long operation the old state and in the second part the new state, which is incorrect?
    Therad1:                                                  Thead2:
    State state = cache.get();     //t1                  
    Result result1 = DoSomethingWithState(state);     //t1    
                               State state = cache.get(); //t2
       ->longOperation1(state); //t1
                               Result result2 = DoSomethingWithState(state); //t2
                                   ->longOperation1(state); //t2
       ->longOperation2(state);//t1
    cache.update(result1);    //t1             
                                   ->longOperation2(state);//t2
                               cache.update(result2);//t2
    Result DoSomethingWithState(State state) {
       longOperation1(state);
       //Imaging Thread1 finish here and update state, when Thread2 is going to execute next method
       longOperation2(state);
    return result;
    class cache {
    private volatile State state = State.newInstance(null, null);
    cache.update(result) {
       this.state = State.newInstance(result.getState, result.getNewFactors);
    get(){
    return state;
    }

    Please don't cross post
    http://stackoverflow.com/questions/6803487/immutable-objects-in-multi-threaded-application-how-does-it-work

  • Using one object in multiple threads

    Are there any drawbacks in using one instance of an object in several threads simultaneously, if this object has no instance variables?
    I need to implement DAO in my project and I just wonder why DAOFactory every time creates a new DAO object, when DAO object doesn't have any instance variables?

    Are there any drawbacks in using one instance of an
    object in several threads simultaneously, if this
    object has no instance variables?
    I need to implement DAO in my project and I just
    wonder why DAOFactory every time creates a new DAO
    object, when DAO object doesn't have any instance
    variables?I don't think there are any problems with this. Since you have no instance variables there isn't really any overlap between the two threads.

  • Would you give me some information about objective-c multi thread

    hello,
    I am studing objective-c multi thread, but have not enough information. would you give me some, please? Thanks very much!

    Have you tried the ADC pages: http://developer.apple.com/macosx/?
    Multi-threading can be a complicated business in any programming language, so good luck!

  • Would you give me some information about objective-c multi thread please

    hello,
    I am studing objective-c multi thread, but have not enough information. would you give me some, please? Thanks very much!

    Hello
    You rang at the wrong door.
    This forum is dedicated to AppleWorks, not to objective-c
    Yvan KOENIG (from FRANCE mercredi 9 août 2006 07:38:25)

  • Passing objects to running threads..

    May anybody give me an idea on how to pass an object to an already running thread??
    i only know how to pass an object to the thread's constructor.

    I guess you are trying to assign a variable dynamically. What you can do is a keep a reference in your thread class (you may have probably done it because you have mentioned about passing an object to your threads constructor). Then give a public setter method to assign an object to that variable. Then you can change that even after you invoke start() of your Thread object.
    example:
    public class MyThread extends Thread{
    private Object obj;
    public void setObject(Object obj){
    this.obj = obj;
    public void run(){
    //your code for the thread
    Then from the class you invoke the thread you can do the following:
    MyThread t = new MyThread();
    t.start();
    Object obj = "your object";
    t.setObject(obj);
    Note: However if your thread is not alive when you assign the object then there will be no use of the passed object to the code inside run() method

  • Objects running on threads

    Hi everyone,
    I have an engine that I have coded that provides a set of services to various applications. Currently the engine is single-threaded, meaning that if more than one person where to access the same instance of the engine there would be shared data violations. I'm sure that you know the drill...
    So, I am about the add a "UserSpace" class to the engine. Each person that logs into the engine will be assigned a user space, within which is stored information that is pertinent to them (and is isolated from all other users).
    I am familiar with using threads to perform lengthy operations (ie: making an object Runnable and calling the start() method to get things going). But I have never used threads in this way before.
    What I mean is that I want to be able to assign a thread to each user space. In other words every user will have their own unique thread just for them. Method calls on the user space do not need to be synchronized because the information within them is, by definition, not shared. If the user space has to make calls to other areas of the engine then those methods would have to be synchronized but I can deal with that.
    So how would I go about accomplishing this? Is it just a case of implementing Runnable as I normally do, calling start() and then make method calls?
    Thanks in advance for your help. :)
    Ben

    I believe you could accomplish what you wish w/3 classes. In accordance with your example and subsequent explanation, they are as follows:
    public class UserSpace {
    private Object mDataThatIsNotShared; // etc.
    public String methodOne() { /*some code */ }
    public void methodTwo(String s) { /*some code */ }
    public class Server {
    // This class would accept socket connections. For each socket
    // connection accepted, create an object of the third class called
    // ServerThread (see below):
    while (true) {
    // The line below blocks until connection:
    Socket socketAccepted=serverSocket.accept();
    ServerThread srvrThrd=new ServerThread(socketAccepted);
    srvrThrd.start();
    public class ServerThread extends Thread {
    private Socket mSocket;
    private UserSpace userSpace;
    ServerThread(Socket socket) {
    mSocket=socket;
    userSpace=new UserSpace(...); //See, each ServerThread owns its own
    public void run() {
    // Do whatever work you want w/UserSpace.
    Of course, this is way overly simplistic...Does not take into account the fact that you could have unlimited threads...i.e., your Server class needs to implement some sort of thread pool, etc.
    Does this help you?
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Missing objects - block diagram

    Hello!
    So... My program it's working fine, but it seems that I cannot see some objects in the block diagram (see the attached image), even if they're working fine. do you know how to show them? because I would like to change something and I don't know how to do that!
    I've seen also that if I try to run the clean up diagram function for the whole program labview crashes!
    I'm working with labview 2010.
    thanks!
    bye!

    I'm sorry, I forgot to attach the file! Here in this image you can see how it appears (left) and how it should be (right)!
    Thanks!
    Bye!
    Attachments:
    Image.JPG ‏87 KB

  • Print Invoice "Object Blocked"

    when the user trying to print the invoice it is givng an error that the object is blocked. the error contains invoice number and the application  3 and output type. i am not able to think where to start investigation, thanks for your support

    Hi
    Will you please check two things :-
    1) in the table VBRK for the said Invoice no. check is there any Billing Block. If it is blocked then you need to remove it.
    2) What is the requirement assigned to the Output Procedure ( IMG --> Sales & Distribution --> Basic Function --> Output Control --> Output Determination >Output determination Using the Condition technique>mainatin Output Determination for Billing Doc-->Maintain Output Determination Procedure) may be your requirement assigned is not getting fulfilled.
    Regards
    Amitesh

  • Need blocking method without blocking main thread

    I have this problem:
    public void blockingMethod() {
      frame.setVisible(true);
      // wait for the user to click on a button on the frame
      return;
    }I want to make a method blocking until the user press a button on the frame. However, I can't make the current thread sleep or wait and then notify it when the button is pressed, because it is the main thread that calls this method. And the main thread is responsible for listening to events and repaint the frame.
    I could solve my problem by using a modal Dialog and let the user enter some data there and then exit the Dialog. Dialog.show() would block until the user exits it again. But I would rather use my frame, so I took a look at the code for Dialog.show() method, and it does something like this:
    EventDispatchThread dispatchThread =(EventDispatchThread)Thread.currentThread();
    * pump events, filter out input events for
    * component not belong to our modal dialog.
    * we already disabled other components in native code
    * but because the event is posted from a different
    * thread so it's possible that there are some events
    * for other component already posted in the queue
    * before we decide do modal show. 
    dispatchThread.pumpEventsForHierarchy(new Conditional() {
      public boolean evaluate() {
        return keepBlocking && windowClosingException == null;
    }, this);But EventDispatchThread is package protected, so I can't do this.
    Any suggestions? I think there are circumstances where you would like a method block, but where it is the main thread that calls the method (out of my control), and you would not like the main thread block unless you could make sure the gui would still repaint and events would run.

    Ah, nm. The main thread is not the same as the event thread.
    Whew! :)
    The first who reply will get the dukes.

  • Re-Initializing Date object in a Thread

    Hi ppl,
    I am actually using a Thread, in which i check the current system time, to perform an operation.
    I use a GreagorianCalendar Object to get the Current Time.
    Calendar d = new GregorianCalendar();The time value stored in the object remains the same throughout the process. Therefore, i reinitialize the object every Millisecond to update the object with the current time.
    d = new GregorianCalendar();Is there any other optimal way to perform this ?
    If this is the only way possible, does it, in any way, affect the Memory, since Object is reinitialized every millisecond. If so, what could be the best possible solution ?
    Code :
    To perform a particular operation at 09:00:00:000
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class SampleThread implements Runnable{
         public void run() {
              try
                   Calendar d = new GregorianCalendar();
                   while(d.get(Calendar.HOUR)!= 9 ||
                             d.get(Calendar.MINUTE)!=0 ||
                             d.get(Calendar.SECOND) != 0 ||
                             d.get(Calendar.MILLISECOND) != 0 )
                        Thread.currentThread().sleep(1);
                        d = new GregorianCalendar();
                   System.out.println("Operation Executed at : "+d.getTime());
                   Thread.currentThread().sleep(1000);
                   d = new GregorianCalendar();
                   Thread.currentThread().run();
              catch (InterruptedException e)
                   e.printStackTrace();
         public static void main(String a[])
              SampleThread st = new SampleThread();
              Thread t = new Thread(st);
              t.start();
    }can the above code be optimized in any way ?

    Hi,
    Your problem is not the TimerTask, but the way you compute a specific time. Run the following program and you will see what is wrong:
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    public class Tomorrow {
        public static void main(String[] args) {
         DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG,
              DateFormat.LONG);
         System.out.println("Your start time is today:       "
              + dateFormat.format(getTomorrowMorning4am()));
         System.out.println("Correct start time is tomorrow: "
              + dateFormat.format(tomorrow9am()));
        private static Date getTomorrowMorning4am() {
         Calendar tomorrow = new GregorianCalendar();
         Calendar result = new GregorianCalendar(tomorrow.get(Calendar.YEAR),
              tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE), 9, 0);
         return result.getTime();
        private static Date tomorrow9am() {
         Calendar calendar = Calendar.getInstance();
         calendar.add(Calendar.DAY_OF_YEAR, 1);
         calendar.set(Calendar.HOUR_OF_DAY, 9);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
         return calendar.getTime();
    }The start time you supply has already been expired when you invoke scheduleAtFixedRate.
    There is a second problem: the interval. What will happen when daylight saving time comes into effect?
    In your case, scheduling at a specific time of the day, you may consider canceling the timertask after completion and schedule a new timertask.
    Piet

  • Using public static object for locking thread shared resources

    Lets Consider the example,
    I have two classes
    1.  Main_Reader -- Read from file
    public  class Main_Reader
         public static object tloc=new object();
           public void Readfile(object mydocpath1)
               lock (tloc)
                   string mydocpath = (string)mydocpath1;
                   StringBuilder sb = new StringBuilder();
                   using (StreamReader sr = new StreamReader(mydocpath))
                       String line;
                       // Read and display lines from the file until the end of 
                       // the file is reached.
                       while ((line = sr.ReadLine()) != null)
                           sb.AppendLine(line);
                   string allines = sb.ToString();
    2. MainWriter -- Write the file
    public  class MainWriter
          public void Writefile(object mydocpath1)
              lock (Main_Reader.tloc)
                  string mydocpath = (string)mydocpath1;
                  // Compose a string that consists of three lines.
                  string lines = "First line.\r\nSecond line.\r\nThird line.";
                  // Write the string to a file.
                  System.IO.StreamWriter file = new System.IO.StreamWriter(mydocpath);
                  file.WriteLine(lines);
                  file.Close();
                  Thread.Sleep(10000);
    In main have instatiated two function with two threads.
     public string mydocpath = "E:\\testlist.txt";  //Here mydocpath is shared resorces
             MainWriter mwr=new MainWriter();
             Writefile wrt=new Writefile();
               private void button1_Click(object sender, EventArgs e)
                Thread t2 = new Thread(new ParameterizedThreadStart(wrt.Writefile));
                t2.Start(mydocpath);
                Thread t1 = new Thread(new ParameterizedThreadStart(mrw.Readfile));
                t1.Start(mydocpath);
                MessageBox.Show("Read kick off----------");
    For making this shared resource thread safe, i am using  a public static field,
      public static object tloc=new object();   in class Main_Reader
    My Question is ,is it a good approach.
    Because i read in one of msdn forums, "avoid locking on a public type"
    Is any other approach for making this thread safe.

    Hi ,
    Since they are easily accessed by all threads, thus you need to apply any kind of synchronization (via locks, signals, mutex, etc).
    Mutex:https://msdn.microsoft.com/en-us/library/system.threading.mutex(v=vs.110).aspx
    Thread signaling basics:http://stackoverflow.com/questions/2696052/thread-signaling-basics
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Windows 8 and Bonjour issues

    I have an Epson NX415 printer scanner connected to an iMac running OSX 10.7.5 through USB. The printer has been shared and I can print from several devices including a Macbook Pro, an iPad, and older Macbook. My wife's previous computer, running Wind

  • In iTunes 11 how do you get Genius recommendations from the iTunes store

    In iTunes 11 how do you get Genius recommendations from the iTunes store. It would appear that I can only get Genius recommendations from my own library. This was easy in iTunes 10 and enabled me to find lots of good artists I had never heard of.

  • What to be mentioned in "Root folder" while configuring J2EE ...

    Hi, I am using Flex Builder 3 (trial version)... While creating new project, i chose Application Server as "J2EE" , selected "Use remote object access service" and selected "LiveCycle Data Services".. In the "Configure J2EE server" page, I unchecked

  • OBIEE Issue - Physical Query not picking cascaded Conditions

    In one the OBIEE Reports, I have given a set of NOT LIKE conditions as below: Session Name is not LIKE (pattern match) '%AUDIT%' AND Session Name is not LIKE (pattern match) '%audit%' AND Session Name is not LIKE (pattern match) '%Audit%' But when we

  • ChaRM: Normal Corrrection: Problem in  /TMWFLOW/TS_READ_TRORDER_HDR

    Folks, I am implementing ChaRM in SOLMAN and have a problem with Normal Correction that I need help with.  When setting a Normal Correction to 'Development Complete' I get the error below. A technical problem occurred when RFC function module /TMWFLO