public void run() {
    //      
    while (!gameOverFlag) {
        //   
        synchronized (this) {
            //     
            if(direction==UP) {checkMove(xHead, yHead-7); moveUp();}
            if(direction==LEFT) {checkMove(xHead-7, yHead); moveLeft();}
            if(direction==RIGHT) {checkMove(xHead+7, yHead); moveRight();}
            if(direction==DOWN) {checkMove(xHead, yHead+7); moveDown();}
        }
        //   
        repaint();
        try {
            //    speed 
            Thread.sleep(level*speed);
        } catch (InterruptedException e) {
        }
    }
}
