Review Questions

9.8 Which one of these events will cause a thread to die?

Select the one correct answer.

  1. The method sleep() is called.

  2. The method wait() is called.

  3. Execution of the start() method ends.

  4. Execution of the run() method ends.

  5. Execution of the thread's constructor ends.

9.9 Which statements are true about the following code?
 public class Joining { static Thread createThread(final int i, final Thread t1) { Thread t2 = new Thread() { public void run() { System.out.println(i+1); try { t1.join(); } catch (InterruptedException e) { } System.out.println(i+2); } }; System.out.println(i+3); t2.start(); System.out.println(i+4); return t2; } public ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.