ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: Waiting in a task thread
Date Fri, 27 Apr 2001 13:59:39 GMT
At 02:43  27/4/01 +0100, Jim Downing wrote:
>Hi all,
>I'm having problems with a section of code in a custom task that attempts to
>stall execution for a period. My code uses
>
>Thread.currentThread().wait(sometime);
>
>but throws an IllegalMonitorStateException ("... a thread has attempted to
>wait on an object's monitor ... without owning the specified monitor. ")
>when the task executes.
>
>What gives? Can I get round it?

I think you are looking for sleep ... wait it a synchronisation primitive.
To use it you would go

Object o = ...;

synchronized( o )
{
  o.wait( 1234 );
}

This would wait 1234 ms or until some one did a o.notify().

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Mime
View raw message