package ru.agolovin;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author agolovin (agolovin@list.ru)
 * @version $Id$
 * @since 0.1
 */

public class Player implements Runnable {

    private ReentrantLock[][] board;

    private int xCell;
    private int yCell;

    private ReentrantLock lock;

    private boolean flag;

    @Override
    public void run() {

    }

    private boolean isCorrectMove(int xCell, int yCell) {
        boolean result = false;

        if ((xCell >= 0) && xCell < this.board.length
                && (yCell >= 0 && yCell < this.board.length)) {
            result = true;
        }

        return result;
    }
}

@@ -15,16 +15,41 @@
 lovin;%0A%0A
+import java.util.Random;%0A
 import j
@@ -395,16 +395,415 @@
 run() %7B%0A
+        this.lock.lock();%0A        int xNew, yNew;%0A%0A        while (!flag) %7B%0A            do %7B%0A                xNew = this.xCell + new Random().nextInt(2);%0A                yNew = this.yCell + new Random().nextInt(2);%0A            %7D while (isCorrectMove(xNew, yNew));%0A        %7D%0A    %7D%0A%0A    public boolean isStopped() %7B%0A        if (!this.flag) %7B%0A            this.flag = true;%0A        %7D%0A        return true;
 %0A    %7D%0A%0A

add test task in part6 chapter7 package2