aspose file tools*
The moose likes I/O and Streams and the fly likes seemingly asynchronous threads actuadeadlock between reading from Scanner and println from a Socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "seemingly asynchronous threads actuadeadlock between reading from Scanner and println from a Socket " Watch "seemingly asynchronous threads actuadeadlock between reading from Scanner and println from a Socket " New topic
Author

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

Piter Smith
Ranch Hand

Joined: Feb 25, 2009
Posts: 31
I'm after asynchronous threading as per:

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


http://www.science.uva.nl/ict/ossdocs/java/tutorial/java/threads/synchronization.html


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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: seemingly asynchronous threads actuadeadlock between reading from Scanner and println from a Socket