Question

Can I send from the Producer Thread on PipedOutputStream the wait()-Signal to the Receiver Thread, so that the Receiver "sleeps" until the notify()-Singal comes from the Producer Thread?

The Task is to check the InputStream in Receiver as soon as the Producer puts bytes on the Stream.

Was it helpful?

Solution

Upon issuing a read call in the receiving thread, the "receiver" will be in "sleep" mode (also called "blocked") until one of the following happens:

  1. The "sender" closed the stream.
  2. The thread, in which the "receiver" runs, is interrupted.
  3. The "sender" sends something down the stream.

These are the only ways you can control the "receiver"'s behaviour.

If you think you must be able to pass signals, then you're most likely doing something wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top