Java Multithreading Question and Answers

25. What's new with the stop(), suspend() and resume() method?
  The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
 
Your Name Your Email-ID
Your Answer
26. Can a lock be acquired on a class?
  Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.
 
Your Name Your Email-ID
Your Answer
27. Can a method be static and synchronized?
  No a static method can't be synchronized.
 
Jagannath,says August 14,2017
While creating singelton can we use static? public synchronized static AccountCreation getInstance() { if (instance==null) { instance = new AccountCreation(); System.out.println("AccountCreation Class Object creatred...!!!"); } else{ System.out.println("AccountCreation Class Object not Creatred just returned Created one...!!!"); } return instance; }
Your Name Your Email-ID
Your Answer
28. Explain Java Thread Life Cycle?
  The life cycle of threads in Java is very similar to the life cycle of processes running in an operating system. During its life cycle the thread moves from one state to another depending on the operation performed by it or performed on it. A Java thread can be in one of the following states.
  • New: A thread that is just instantiated is in the new state. When a start() method is invoked, the thread moves to the ready state from which it is automatically moved to runnable state by the thread scheduler.
  • Runnable: A thread executing in the JVM is in running state.
  • Blocked: A thread that is blocked waiting for a monitor lock is in this state. This can also occur when a thread performs an I/O operation and moves to next (runnable) state.
  • Waiting: A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
  • Timed_waiting: A thread that is waiting for another thread to perform an action up to a specified waiting time in this state.
  • Terminated: A thread that has exited is in this state.
 
Your Name Your Email-ID
Your Answer
12345678910 Page 7 of 10