Java Threading Question and Answers

21. What is the use of start() function in starting a thread?
  The start() method tells the Java Virtual Machine that it needs to create a system specific thread. After creating the system resource, it passes the Runnable object to it to execute its run() method.
Calling the run() method directly has the "Thread" execute in the same thread as the calling object, not in a separate thread of execution, as intended.
 
Your Name Your Email-ID
Your Answer
22. How does serialization work?
  It’s like FIFO method (first in first out).
 
Your Name Your Email-ID
Your Answer
23. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?
  When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.
 
Your Name Your Email-ID
Your Answer
24. What is Future Task Class?
  Future Task is the base implementation class of Future interface and we can use it with Executors for asynchronous processing. Most of the time we don't need to use FutureTask class but it comes real handy if we want to override some of the methods of Future interface and want to keep most of the base implementation.
 
Your Name Your Email-ID
Your Answer
1234567 Page 6 of 7