Java Multithreading Question and Answers

13. What are different ways in which a thread can enter the waiting state?
  A thread can enter the waiting state by the following ways
  • Invoking its sleep() method,
  • By blocking on I/O
  • By unsuccessfully attempting to acquire an object's lock
  • By invoking an object's wait() method
  • It can also enter the waiting state by invoking its (deprecated) suspend() method.
 
Your Name Your Email-ID
Your Answer
14. What are the benefits of multi threaded programming?
 
  • In Multi Threaded programming, multiple threads are executing concurrently that improves the performance because CPU is not idle incase some thread is waiting to get some resources.
  • Multiple threads share the heap memory, so it's good to create multiple threads to execute some task rather than creating multiple processes.
 
Your Name Your Email-ID
Your Answer
15. Which method is used to create the daemon thread?
  setDaemon method is used to create a daemon thread.
 
Your Name Your Email-ID
Your Answer
16. What state is a thread in when it is executing?
  An executing thread is in the running state.
 
Your Name Your Email-ID
Your Answer
12345678910 Page 4 of 10