aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread with same instance as lock Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread with same instance as lock Query" Watch "Thread with same instance as lock Query" New topic
Author

Thread with same instance as lock Query

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634



Is the following output possible ?

i think it is possible.
both threads lock on same instance,so they would block each other
any one either main or thread-0 thread-1 can run first
but i think jvm can stop thread 0 in between and run main and then switch back to thread-0

jusbeforesleep
Thread-0
main
Thread-0
jusbeforesleep
Thread-1
Thread-1


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You are correct.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
 
subject: Thread with same instance as lock Query