title: Creating Dice game in java using Multithreading
body: <p>I want to provide implementation of a 4 player dice game in which each player is implemented as a thread . Each player get a chance to throw the dice in order of player number . each throw dies return a number 1 to 6 only . the game stop whenever any player scores 25 point or more print winner player .</p>
  
  <p>I am Thinking of creating classes </p>
  
  <p><strong>Dice</strong> for handling Dice</p>
  
  <p><strong>Board</strong> For handling all Thread and Player Score</p>
  
  <p><strong>TheGame</strong>  for Starting game</p>
  
  <p><em>My class Dice</em></p>
  
  <pre><code>import java.util.Random;
  
  public class Dice {
  Random dice;
  public Dice()
  {
  dice=new Random();
  }
  
  public int throwDice()
  {
      int a= dice.nextInt(70);
      a=a/10;
      if (a==0)
          return 1;
      else return a;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><em>My Player Class</em></p>
  
  <pre><code>public class Player extends Thread {
  Board board;
  int num;
  public Player(Board b,int n)
  {
  board=b;
  num=n;
  }
  public void run()
  {
  System.out.println("Player "+num+" is started, playing game...");
  while(board.flag)
  {
  board.play(num);    
  }
  }
  }
  </code></pre>
  
  <p><em>Game Class</em></p>
  
  <pre><code>public class TheGame {
  
  
      public static void main(String[] args) {
          System.out.println("Initializing board...");
          Board b=new Board();  //Creating object of class board
          System.out.println("Initializing players...");
          Player p1=new Player(b,1); // Every player is Thread
          Player p2=new Player(b,2);
          Player p3=new Player(b,3);
          Player p4=new Player(b,4);
          p1.start(); //Starting Thread
          p3.start();
          p2.start();
          p4.start();
      }
  
  }
  </code></pre>
  
  <p>I am not able to think Logic or decide where to start in class Board. 
  Please Help me with Board code</p>
  
  <p>This is not assignment or homework .
  I want to do it by myself but don't have any deep idea about Synchronization in Threading</p>
  
  <p>I am trying to code i am not asking complete tutorials i am just asking how do i set order when player 1(thread) get execute after player 1 have done his chance.</p>