2012-02-22 3 views
0

ScheduledExecutorService를 사용하고 있으며 scheduleFuture에서 cancel 메서드를 호출 한 후에 Runnable을 예약 할 수 없습니다. cancel() 뒤에 scheduleAtFixedRate(runnable, INITIAL_DELAY, INTERVAL, TimeUnit.SECONDS)을 호출해도 아무런 변화가 없습니다. cancel() 메서드를 호출 한 후 ScheduledExecutorService을 다시 시작할 수 있습니까?scheduleexecutorservice를 여러 번 시작하고 중지하는 방법

답변

0

Future 메모와 해당 구현 FutureTask을 검토하십시오.

cancel() 메소드를 호출하는 효과가 있습니다 :

  • subsequent calls to isDone() will always return true. Subsequent
    calls to isCancelled() will always return true if this method
    returned true.
  • Once the computation has completed, the computation cannot be restarted or cancelled.

의미 경우 isDone() 반환 true를 호출하면 cancel()에 전화를했다 여부, 당신은 당신의 서비스의 동일한 인스턴스를 사용할 수 없습니다.

+0

서비스를 시작하고 중지 한 다음 다시 시작하는 방법을 제안하십시오. – user1128158

관련 문제