Resched. timer after cancel gives “java.lang.IllegalStateException: Timer cancelled.”

前端 未结 4 1781
走了就别回头了
走了就别回头了 2021-01-18 01:09

i would like to know whether i can schedule the timer again after i cancelled it. It was stated here, http://www.coderanch.com/t/452066/java/java/Exception-timer-IllegalStat

4条回答
  •  执念已碎
    2021-01-18 01:39

    Yeah, cancelling the timer terminates its thread so you can't use it again. The timer doesn't have any built-in methods for pausing. You can cancel the timer when you want to "pause" and make a new one when you want to "resume".

提交回复
热议问题