Your Name:

13.1 A thread could be inactive because it

(a) is unlucky
(b) could be waiting for a share of processing time
(c) could be waiting for information
(d) answer (b) or (c)

13.2 To implement threads, a programmer needs to

(a) do nothing, because the threads are transparent
(b) just initiate the thread objects and let them run
(c) make sure that there is enough memory and other resources for the threads to work
(d) instantiate the threads, keep them synchronized and detect when they should finish

13.3 The nucleus of a thread is the

(a) run method
(b) start method
(c) Thread class
(d) Runnable interface

13.4 In the Spots thread, in example 13.1, what is the effect of the following lines of code?

try {
sleep (500);
catch (InterruptrdException e) {

(a) the program slows down after 200 iterations of the loop
(b) the computer is put into sleep mode for 500 seconds
(c) the thread stops for 500 milliseconds, after which an InterruptedException is thrown by the sleep method, and execution continues
(d) the thread yields execution to another waiting thread for half a second

13.5 Certain operations in a threaded program need to be synchronized

(a) to prevent deadlock
(b) to allow them to change the system's time
(c) to allow the synchronized method, which contains code that modifies global variables or the program state, to finish execution completely before another method is called
(d) so that they do not have to wait at a red traffic light at every intersection

13.6 The Display class has neither an inner class extending Thread, nor a run method. How, then, does it have the attributes of a thread?

(a) It has a ready method
(b) It has a watcher class which calls wait and notify
(c) all main methods are threads
(d) answers (a) and (b)

13.7 In which package is the Thread class declared?

(a) java.util
(b) java.lang
(c) java.io
(d) java.applet

13.8 A thread ends when

(a) the program that created it ends
(b) it calls stop()
(c) it reaches a natural conclusion, e.g. its loop finishes
(d) all other threads of that class end

13.9 To start a new car park in Example 13.4, we could say:

(a) new CarThread ("North", 450);
(b) new CarThread ("North", 450).start ();
(c) new ViewPoint ("View2"), 450);
(d) new ViewPoint ("View2"), 450).start();

13.10 The Display class uses the following data structure to keep track of data items that can be input:

(a) linked list
(b) array
(c) hash table
(d) vector