Created
May 27, 2012 12:01
-
-
Save heyLu/2810996 to your computer and use it in GitHub Desktop.
Threads and stopping.
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
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