Skip to content

Instantly share code, notes, and snippets.

@heyLu
Created May 27, 2012 12:01
Show Gist options
  • Save heyLu/2810996 to your computer and use it in GitHub Desktop.
Save heyLu/2810996 to your computer and use it in GitHub Desktop.
Threads and stopping.
class ThreadBleh extends Thread {
private boolean areWePlayingNow = false;
public void run() {
while(true) {
if(areWePlayingNow) {
// do something
} else {
// don't do something ;)
}
Thread.sleep(1000);
}
}
public void pause() {
this.areWePlayingNow = false;
}
public void resume() {
this.areWePlayingNow = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment