• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

thread

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ANSWER TRUE/FALSE.
A)If only one thread is blocked in the wait method of an object and another thread
execute the notify method on that same object, then the first thread immediately
resumes execution.
B.) If a thread is blocked in the wait method of an object, and another thread executes
the notify method on the same object, it is still possible that the first thread might
never resume execution.
C.) If a thread is blocked in the wait method of an object, and another thread executes
the notify method on the same object then the first thread definitely resumes execution
as a direct and sole consequence of the notify call.

d)If two thread are blocked in the wait method of an object, and another thread
executes the notify method on the same object then the thread that executed the wait
call first definitely resumes execution as
a direct and sole consequence of the notify
call

THE ABOVE GIVEN QUESTION IS FROM PONY MOCK EXAM.LET ME KNOW THE CORRECT ONE'S.TO ME B OPTION SEEM'S TO BE CORRECT BUT NOT SURE,LET ME KNOW THE CORRECT ONE'S.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fraternity,
Another badly worded mock ...
The notify method is never executed on an object. It is just called:
notify();
It is up to the JVM scheduler to move waiting thread from the wait state. If you use
notifyAll();
Then all waiting processes are removed from the wait state.
When threads are moved from the wait state they are placed in the ready state. This does not guarentee that the thread will ever get moved to the run state.
Therefore, assuming bad english, I would agree with you on the choice of B.
Regards,
Manfred.
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manfred,
just to be clear, notify() is an instance method of the
Object class and does indeed get called "on an object."
as in:
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how about the last option D.
 
Are you here to take over the surface world? Because this tiny ad will stop you!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic