[concurrency-interest] When do you use wait/notify?

Joseph Bowbeer jozart@blarg.net
Sun, 25 Jan 2004 00:40:48 -0800


In what ways is the proposed java.util.concurrent.Future interface

Comparing jet Future with juc Future,

1. I see that they both have get methods.

2. jet's isSet method looks similar to juc's isDone.

3. A notable difference is that jet provides a set method in the interface,
whereas juc only provides a set method in concrete impls such as FutureTask.

----- Original Message ----- 
From: "Ian Griffiths" <ian.griffiths@yellow-b.com>
To: <concurrency-interest@altair.cs.oswego.edu>
Sent: Sunday, January 25, 2004 12:15 AM
Subject: [concurrency-interest] When do you use wait/notify?

I am new to this list and should like to apologize if something has
escaped my attention.

I still use wait notify to handle a very simple Future implementation.

In my application, I have a number of objects I may be asked to provide
and have a very low priority thread that will instantiate them all over

However many of the objects may also be produced as by-products of
other tasks that get them from other, parallel, processes or that
create them in response to an urgent request. thus sparing my basic
thread the tiresome job of re-calculating them from scratch.

To do this I use a very implementation of a Future:

package jet.util.concurrency;

 * A Future is an object that encapsulates a value that may
 * only appear at a later date.
public interface Future {

* Method getValue.
* @return Object the value of the Future
* @throws InterruptedException If the wait is interrupted
    public Object getValue() throws InterruptedException;
* Method isSet Says whether a value has been set.
* @return boolean true if a value has been set.
    public boolean isSet();
* Method setValue.Set the value for this future
* @param value The value to be set.
    public void setValue(Object value);

The important point is that the Future is not linked to any specific
task, as I do not know how it will be obtained when I create the Future.

Best Regards.