• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread.State.NEW

 
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: 1951
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic