Multithreading


  1. Which of these method wakes up all the threads?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    notifyAll() wakes up all the threads that called wait() on the same object. The highest priority thread will run first.


  1. Which of these method wakes up the first thread that called wait()?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    notify()



  1. Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    wait() method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor. This helps in avoiding polling and minimizes CPU idle time.


  1. Which of this method is used to avoid polling in Java?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Polling is a usually implemented by looping in CPU is wastes CPU time, one thread being executed depends on other thread output and the other thread depends on the response on the data given to the first thread. In such situation CPU time is wasted, in Java this is avoided by using methods wait(), notify() and notifyAll().



  1. Which of these keywords are used to implement synchronization?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    synchronized