Chapter 14. Waiting for the Full Timeout


In Java, two threads can communicate with each other through the wait-notify mechanism (see Chapter 8, "Inter-thread Communication"). When a thread invokes one of the wait() methods of Object, an optional timeout value can be specified. The thread does not return from the wait(long msTimeout) call until it is notified by another thread, the specified millisecond timeout has elapsed, or it is interrupted. It is obvious when it has been interrupted as an InterruptedException is thrown. But other than that, wait() does not return any information as to whether it was notified or just timed ...

Get Java Thread Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.