Advertisement
Guest User

threadGame.java

a guest
May 24th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package nexus;
  2.  
  3. public class threadGame implements Runnable{
  4.     public Thread game; //Thread of Game.Execute the game
  5.     //Start of: "Thread of game"
  6.     public synchronized void startGame(){ //This void start the game
  7.         updateGame.gameIsOn = true; //Import updateGame and set this boolean to true
  8.         game = new Thread(this, "Gráficos"); //Create the thread
  9.         game.start(); //Starts the thread
  10.     }
  11.     public synchronized void finishGame(){ //This void end the game
  12.         updateGame.gameIsOn = false; //Import updateGame and set this boolean to false
  13.         try{
  14.             game.join(); //Try to end the thread
  15.         }catch(InterruptedException e){
  16.             e.printStackTrace();
  17.         }
  18.     }
  19.     public void run() {
  20.         updateGame.timer(); //Imports timer
  21.     }
  22.     //End of: "Thread of game"
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement