Created
May 11, 2015 19:50
-
-
Save InputNeuron/6fe3ee640f5f1b27caa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public synchronized void cancel(Runnable task) { | |
| SchedulerTimerTask ticket = timerTasks.remove(task); | |
| if (ticket != null) { | |
| ticket.cancel(); | |
| // now clear the ticket so we can remove the reference to the | |
| // underlying task. This is necessary to allow GC to take effect. | |
| // Otherwise the Runnable will still have a reference and hog | |
| // memory. | |
| ticket.clear(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment