• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

seemingly asynchronous threads actuadeadlock between reading from Scanner and println from a Socket

Piter Smith
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm after asynchronous threading as per:

The Producer and Consumer in this example share data through a common CubbyHole object.


but with i/o. For local i/o, my Producer:

and my consumer as so:

All that the driver does is to pass the same reference of CubbyHole, a JavaBean with one field, to each thread:

However, the output clearly shows a deadlock type scenario:

because the consumer never comes back to echo or log the CubbHole instance.

So, just using POJO's and the Producer-Consumer pattern, how do I resolve this seeming deadlock?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic