Discussion
Sample06 is run - what will be the output?
public class Sample06
{
static final Runnable NOTHING = new Runnable()
{
public void run() { }
};
public static void main(String[] args) throws InterruptedException
{
Thread probe = new Thread(NOTHING);
System.out.print(probe.getState());
probe.start();
probe.join();
System.out.print(" " + probe.getState());
}
}
Answer: B
A constructed but unstarted thread is NEW, and after join() has returned the thread has certainly died, so it reports TERMINATED. Those are the two points in a thread's life where the state is predictable. There is no DEAD constant; that name belongs to older documentation.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development