Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making sure I have this dead lock concept without statics correct

 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just so I have this clear..in the code below if the two objects had NOT been defined as static then a deadlock situation couldn't occur could it? Since each Thread object would have it's own Test object and thus it's own instances of obj1 and obj2 they would never get locked since m1() and m2() would always be waiting to be finsihed before the next one was called. (I would think the output could still not be determined, though, regardless of whether the Objects obj1 and obj2 were static or not).
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. If variables were non static, methods wouldn't be synchonized at all. And no deadlock would be possible. The same object must be used for properly synchronization.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic