Discussion
Sample54 is run - what will be the output?
public class Sample54 extends Thread
{
public void run()
{
try
{
Thread.sleep(5000);
}
catch (InterruptedException ignored)
{
}
}
public static void main(String[] args) throws InterruptedException
{
Sample54 sleeper = new Sample54();
sleeper.start();
Thread.sleep(200);
Thread.State observed = sleeper.getState();
sleeper.interrupt();
System.out.println(observed);
}
}
Answer: B
A thread inside a call that will give up after a stated interval reports TIMED_WAITING, which covers sleep, wait with a timeout and join with a timeout. Plain WAITING is for the untimed forms, and BLOCKED is reserved for waiting on a monitor lock.
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