Home / Java Programming / Threads :: General Questions

Java Programming :: Threads

  1. Which will contain the body of the thread?

  2. A.
    run();
    B.
    start();
    C.
    stop();
    D.
    main();

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which method registers a thread in a thread scheduler?

  4. A.
    run();
    B.
    construct();
    C.
    start();
    D.
    register();

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Assume the following method is properly synchronized and called from a thread A on an object B:

    wait(2000);

    After calling this method, when will the thread A become a candidate to get another turn at the CPU?

  6. A.
    After thread A is notified, or after two seconds.
    B.
    After the lock on B is released, or after two seconds.
    C.
    Two seconds after thread A is notified.
    D.
    Two seconds after lock B is released.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following will not directly cause a thread to stop?

  8. A.
    notify()
    B.
    wait()
    C.
    InputStream access
    D.
    sleep()

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which class or interface defines the wait(), notify(),and notifyAll() methods?

  10. A.
    Object
    B.
    Thread
    C.
    Runnable
    D.
    Class

    View Answer

    Workspace

    Discuss Discuss in Forum


  11.  public class MyRunnable implements Runnable

     {

         public void run()

        {

          // some code here

        }

      }

    which of these will create and start this thread?

     

  12. A.

    new Runnable(MyRunnable).start();

    B.

    new Thread(MyRunnable).run();

    C.

    new Thread(new MyRunnable()).start();

    D.

    new MyRunnable().start();

    View Answer

    Workspace

    Discuss Discuss in Forum