Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread.State.NEW  RSS feed

 
Sankaranarayanan Viswanathan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!