• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem of using Pipe in threads

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I have encountered a "java.io.IOException: Write end dead" in the
following code:



From my observation, whenever the timer thread is killed the pipe will be
automatically broken. What's the cause of this exception?
I ran the above code on java version "1.5.0_06" and Windows XP home sp2.
Thanks in advance.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if your problem is the same as the one I had with PipedReader/Writer, but it might be, so I'll share it.

The documentation doesn't say so, but UTSL reveals that PipedReader/Writer expect exactly one thread to do the reading and one thread to do the writing. If one of those threads dies, it considers the pipe broken.

So, you can't do what I tried to do. I had a PipedReader open on one thread, connected to a PipedWriter. I tried to write snippets to the PipedWriter from various threads. But when the first writing thread died, so did my PipedReader/Writer.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never used PipedReader / PipedWriter, but for PipedInputStream / PipedOutputStream, it seems to keep track of only the last thread that read or write to the pipe. So...

When I got an IOException, due to a thread death on the other side of the pipe, I just waited until another thread used the other side of the pipe, and tried again. This worked because my threads rarely died, it only happened when the application changed users.

Henry
 
Guy Jay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much.
Now i try to prevent killing the timer thread before the main thread using the pipe.
 
reply
    Bookmark Topic Watch Topic
  • New Topic