Multi Threading
© examsiri.com
Question : 14 of 44
Marks:
+1,
-0
Given:
Assume that sleep(n) executes in exactly n milliseconds, and all other code execute in an insignificant amount of time.
Place the fragments in the output area to show the result of running this code.
1.interrupted
2. ran
3.started
4.interruption
5.ended
6.InterruptedException
7.(no more output)
Runnable r = new Runnable() {
 public void run() {
  try {
   Thread.sleep(1000) ;
  } catch (InterruptedException e) {
   System.out.printIn("interrupted");
  }
   System.out.printIn("ran");
  }
 };
Thread t = new Thread(r);
t.start();
System.out.println("started");
t.sleep(2000);
System.out.println("interrupting");
t.interrupt();
System.out.print In("ended");
Assume that sleep(n) executes in exactly n milliseconds, and all other code execute in an insignificant amount of time.
Place the fragments in the output area to show the result of running this code.
1.interrupted
2. ran
3.started
4.interruption
5.ended
6.InterruptedException
7.(no more output)
Go to Question: