Java Programming :: Threads
-
What is the name of the method used to start a thread execution?
-
Which two are valid constructors for Thread?
- Thread(Runnable r, String name)
- Thread()
- Thread(int priority)
- Thread(Runnable r, ThreadGroup g)
- Thread(Runnable r, int priority)
-
Which three are methods of the Object class?
- notify();
- notifyAll();
- isInterrupted();
- synchronized();
- interrupt();
- wait(long msecs);
- sleep(long msecs);
- yield();
-
class X implements Runnable { public static void main(String args[]) { /* Missing code? */ } public void run() {} }
Which of the following line of code is suitable to start a thread ?
-
The following block of code creates a Thread using a Runnable target:
Runnable target = new MyRunnable(); Thread myThread = new Thread(target);
Which of the following classes can be used to create the target, so that the preceding code compiles correctly?
-
Which cannot directly cause a thread to stop executing?
-
Which two of the following methods are defined in class Thread?
- start()
- wait()
- notify()
- run()
- terminate()
-
Which three guarantee that a thread will leave the running state?
- yield()
- wait()
- notify()
- notifyAll()
- sleep(1000)
- aLiveThread.join()
- Thread.killThread()
-
Which of the following will directly stop the execution of a Thread?
-
Which method must be defined by a class implementing the java.lang.Runnable interface?