Created
February 18, 2014 00:53
-
-
Save bjpeterdelacruz/9062414 to your computer and use it in GitHub Desktop.
Solution to Bug Patrol #1
This file contains 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
// ... | |
if (!this.serialsSet.contains(serial)) { // if (!flag) { | |
this.serialsSet.add(serial); // flag = true; | |
Runnable task = new Runnable() { | |
/** {@inheritDoc} */ | |
@Override | |
public void run() { | |
// Use try-finally. Before the thread dies, it will reset the boolean variable. | |
try { | |
processSerial(serial); | |
} | |
finally { | |
serialsSet.remove(serial); // flag = false; | |
} | |
} | |
}; | |
this.scheduler.schedule(task, NUM_SECONDS, | |
TimeUnit.SECONDS); | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment