private Logger logger = LoggerFactory.getLogger( getClass() );
public void executeTask( Task task0 )
throws TaskExecutionException
{
BuildProjectTask task = (BuildProjectTask) task0;
task.start();
logger.info( "Task:{} cancelled: {}; done: {}", task, task.isCancelled(), task.isDone() );
long time = System.currentTimeMillis();
long endTime = task.getExecutionTime() + time;
for ( long timeToSleep = endTime - time; timeToSleep > 0; timeToSleep = endTime - System.currentTimeMillis() )
{
try
{
logger.info( "Sleeping {} ms (interrupts ignored: {} )", timeToSleep, task.ignoreInterrupts() );
Thread.sleep( timeToSleep );
task.done();
logger.info( "Task completed normally: {} cancelled: {}; done: {}", task, task.isCancelled(),
task.isDone() );
}
catch ( InterruptedException e )
{
if ( !task.ignoreInterrupts() )
{
task.cancel();
logger.info( "Task cancelled: {} cancelled: {} ; done: {}", task, task.isCancelled(),
task.isDone() );
throw new TaskExecutionException( "Never interrupt sleeping threads! :)", e );
}
else
{