Synchronization?
-
I've got two classes,
Day
andHour
, running in separate threads. At certain points within each, they will create an instance of a third class,TZ
, and call one of its methods,retrieve()
. Theretrieve()
method is synchronized, like:public synchronized void retrieve()
{
Thread thread = new Thread(new Runnable()
{
@Override
public void run()
{
// do some lengthy work
}
});thread.start();
}
The work in
retrieve()
only needs to be done once, by whichever ofDay
orHour
gets to it first. How can I accomplish this? Thanks. DC"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles