© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Thread▼

Java Interview Questions On Thread

1. When a thread is created and started, what is its initial state?

Answer
A thread is in the ready state after it has been created and started

2. What invokes a thread's run() method?

Answer
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

3. What method is invoked to cause an object to begin executing as a separate thread?

Answer
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread

4. What is the purpose of the wait(), notify(), and notifyAll() methods?

Answer
The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready

5. What are the high-level thread states?

Answer
The high-level thread states are ready, running, waiting, and dead

6. What happens when a thread cannot acquire a lock on an object?

Answer
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.

7. Describe synchronization in respect to multithreading?

Answer
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors. 

Next
1 2
SLogix Student Projects
bottom