Pergunta

Is Future.get( timeout, unit ) susceptible to the same type of spurious wakeup as documented for Object.wait() and Condition.await() in Javadoc?

someType  result;
Future<someType> future = executor.submit( new callableTask() );

result = future.get( 1000, TimeUnit.MILLISECONDS );

Presume that the thread does NOT end before the timeout, is it possible that it won't wait 1000ms? Seems like it has to wait the full timeout (and generate a timeout exception), otherwise what would the result be?

Foi útil?

Solução

No, because it uses higher synchronization primitive

java.util.concurrent.locks.AbstractQueuedSynchronizer
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top