package ru.napadovskiy.bomberMan;

/**
 * Package of Multithreading.
 * Main class for test.
 * @author Napadovskiy Bohdan
 * @version 1.0
 * @since 10.10.2017
 */
public class Game {

    /**
     * Main method for game.
     * @param args array string.
     */
    public static void main(String[] args) {

        Game game = new Game();

        final int xSize = 8;

        final int ySize = 8;

        final int countOfMonsters = 5;


        GameBoard gameBoard = new GameBoard(xSize, ySize);


//        for (int i =0; i < countOfMonsters; i++) {
//
//            //new Thread(new Monster(gameBoard).setUnitInPosition()).start();
//        }
//
//        Thread heroThread = new Thread(hero);
//        heroThread.start();
//        heroThread.interrupt();
    }

}

@@ -28,16 +28,101 @@
 erMan;%0A%0A
+import java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0A
 /**%0A * P
@@ -267,140 +267,493 @@
  %7B%0A%0A
+%0A
     
-/**%0A     * Main method for game.%0A     * @param args array string.%0A     */%0A    public static void main(String%5B%5D args
+private final int countOfMonsters = 5;%0A%0A    private final int xSizeBoard = 8;%0A%0A    private final int ySizeBoard = 8;%0A%0A    private  final GameBoard board;%0A%0A%0A    private static ExecutorService service = Executors.newCachedThreadPool();%0A%0A    private Game(int xSize, int ySize) %7B%0A        this.board = new GameBoard(xSize, ySize);%0A%0A    %7D%0A%0A    private void addHero() %7B%0A%0A        if (this.board.getBoard()%5B0%5D%5B0%5D != null) %7B%0A            if (this.board.getBoard()%5B0%5D%5B0%5D.tryLock()
 ) %7B%0A
-%0A
         
 Game
@@ -752,41 +752,68 @@
     
-Game game = new Game(
+        Hero hero = new Hero(0, 0, board, service
 );%0A
-%0A
         
 fina
@@ -812,308 +812,478 @@
     
-final int xSize = 8;%0A%0A        final int ySize = 8;%0A
+    %7D%0A        %7D else %7B%0A            Hero hero = new Hero(0, 0, board, service);%0A        %7D
 %0A    
+%7D%0A%0A
     
-final int countOfMonsters = 5;%0A%0A%0A        GameBoard gameBoard = new GameBoard(xSize, ySize);%0A%0A%0A//        for (int i =0; i %3C countOfMonsters; i++) %7B%0A//%0A//            //new Thread(new Monster(gameBoard).setUnitInPosition()).start
+private void addMonster() %7B%0A        if (this.board.getBoard()%5B3%5D%5B3%5D != null) %7B%0A            if (this.board.getBoard()%5B3%5D%5B3%5D.tryLock()) %7B%0A                Monster monster = new Monster(3,3, board,service);%0A            %7D%0A        %7D else %7B%0A            Monster monster = new Monster(3,3, board,service);%0A        %7D%0A    %7D%0A    private void initGame() %7B%0A        addHero
 ();%0A
-//
         
 %7D%0A//
@@ -1282,71 +1282,225 @@
     
-%7D%0A//%0A//        Thread heroThread = new Thread(hero
+addMonster();%0A%0A    %7D%0A%0A%0A%0A    /**%0A     * Main method for game.%0A     * @param args array string.%0A     */%0A    public static void main(String%5B%5D args) %7B%0A%0A        Game game = new Game(8, 8);%0A        game.initGame(
 );%0A
-//
         
 hero
@@ -1499,62 +1499,161 @@
     
-heroThread.start();%0A//
+try %7B%0A            Thread.sleep(5000);%0A 
        
- heroThread.interrupt
+%7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        service.shutdown
 ();%0A
+%0A
     

work with test task