This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread safety and concurrent access

 
Siddharth Raja
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 65
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not thread safe, because your code just locks on different instance of "tester" class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic