あなたのアップデートからは、それが何をするのかを説明するTimer.cancelという意味に見えます。私はあなたがjava.util.Timer
としてjavax.swing.Timer
がstop()メソッド、およびjavax.management.timer.Timer
とsun.misc.Timer
持つ(持っているストップ()メソッドをではなく、あいまいされている)しない意味を前提と
/**
* Terminates this timer, discarding any currently scheduled tasks.
* Does not interfere with a currently executing task (if it exists).
* Once a timer has been terminated, its execution thread terminates
* gracefully, and no more tasks may be scheduled on it.
*
* <p>Note that calling this method from within the run method of a
* timer task that was invoked by this timer absolutely guarantees that
* the ongoing task execution is the last task execution that will ever
* be performed by this timer.
*
* <p>This method may be called repeatedly; the second and subsequent
* calls have no effect.
*/
public void cancel() {
synchronized(queue) {
thread.newTasksMayBeScheduled = false;
queue.clear();
queue.notify(); // In case queue was already empty.
}
}
私の知る限り、そのAこのタイマーをIO用に使用することは非常に悪い考えです。これはGUIスレッドを使用し、一定期間ロックアップする可能性があるからです。
あなたがものを実行している)、それは新しいタスクの送信を停止見ることができますが、(中断または停止しないコード
/**
* Stops the <code>Timer</code>,
* causing it to stop sending action events
* to its listeners.
*
* @see #start
*/
public void stop() {
getLock().lock();
try {
cancelEvent();
timerQueue().removeTimer(this);
} finally {
getLock().unlock();
}
}
を見てみます。
問題の範囲を明確にするために、私は同じことをやっている複数のタイマーを持っているかもしれません。これらはすべてこの問題に対処する必要があります。 – merlin2011
'#stop()'ではなく 'java.util.Timer#cancel()'を意味しますか? – Ramon