• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication Patterns Between Threads

 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
From Core Java by Horstmann and Cornell:
"Some programmers find Java thread synchronization overly deadlock-prone because
they are accustomed to different mechanisms that don't translate well to Java. Simply
trying to turn semaphores into a nested mess of synchronized blocks can indeed be a
recipe for disaster."
{I take he means this:

}
"Our advice, if you get stuck with a deadlock problem, is to step back and ask yourself
what communication pattern between threads you want to achieve. Then create another
class for that purpose. That's the Object-Oriented way, and it often helps disentangle
the logic of multithreaded programs."
Question:
Can anyone expand on the following sentence through examples or discussion to make
the authors point more understandable:

...ask yourself what communication pattern between threads you want to achieve. Then
create another class for that purpose.

Thanks,
Javini Javono
[ February 15, 2004: Message edited by: Javini Javono ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic