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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread.State.NEW" Watch "Thread.State.NEW" New topic


Sankaranarayanan Viswanathan

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 3: BLOCKED
Self State 1: NEW
Self State 2: NEW
State 4: WAITING
Self State 3: NEW
Jelle Klap

Joined: Mar 10, 2008
Posts: 1869

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.
It is sorta covered in the JavaRanch Style Guide.
subject: Thread.State.NEW