aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread.State.NEW Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread.State.NEW" Watch "Thread.State.NEW" New topic
Author

Thread.State.NEW

Sankaranarayanan Viswanathan
Greenhorn

Joined: Sep 27, 2011
Posts: 5


The above code gives the following output on my machine. Can someone help me understand how the output of Self State can ever be NEW? Per my understanding NEW is only when a thread has not yet been started.

State 1: NEW
State 2: RUNNABLE
State 3: BLOCKED
Self State 1: NEW
Self State 2: NEW
State 4: WAITING
Self State 3: NEW
State 5: TERMINATED
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1771
    
    7

The getState() call inside the run() method returns the state of the ClassA instance you've passed to the Thread constructor.
That Thread instance will never actually run, it will just have its run() method called.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread.State.NEW