Search This Blog

Friday, January 28, 2011

Question 5

There are three Threads trying to invoke a method of an object. This method is a synchronized method to prevent conflict between Threads. While Thread1 is executing the method, Thread2 and Thread3, in that order attempt to invoke the method.
What happens when Thread1 exits the method?

Options : (Choose one answer)

a. Thread2 will be the first waiting Thread to execute the method.

b. Thread3 will be the first waiting Thread to execute the method.

c. The order In which the Ttread2 and Thread3 will invoke the method cannot be determined.

d. None of these.

Answer : C (The order in which the Thread 2 and Thread 3 will invoke the method cannot be determined).

Selection of a thread from the thread pool is completely cannot be predicted as the underlying operating system has different mechanisms to run a thread.

Question 5SocialTwist Tell-a-Friend

No comments:

Post a Comment