aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread safety and concurrent access 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 safety and concurrent access" Watch "thread safety and concurrent access" New topic
Author

thread safety and concurrent access

Siddharth Raja
Greenhorn

Joined: Nov 11, 2013
Posts: 18


is the variable 'x' prevented from concurrent access
is the above code thread safe?

if the following output had to be guaranteed, what changes should be made to the code?
main: 0
Thread-0: 1 or Thread-1: 1
Thread-1: 3 or Thread-0: 3
main: 4
Myyron Murray Latorilla
Ranch Hand

Joined: Dec 10, 2009
Posts: 65

Not thread safe, because your code just locks on different instance of "tester" class.


OCPJP6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thread safety and concurrent access
 
Similar Threads
What is the output
Threads
static void main(String args[]) is working why??????
why is it wrong?
threads