try { long before, after, sleep; stop: while (isUp()) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!isUp()) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { setUp(false); end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) {  } } } catch (Throwable ex) { ex.printStackTrace(); } }
repaint(); }
			public void run() {				try {					long before, after, sleep;					stop: while (isUp()) {						before = System.currentTimeMillis();						synchronized (Tetris.class) {							while (pause) {								try {									System.out.println("waiting");									Tetris.class.wait();									System.out.println("back from waiting");								} catch (InterruptedException ignore) {								}								if (!isUp())									break stop;							}						}						if (hasRoom(bi, x, y + 1)) {							y++;							repaint();						} else {							newBlock();							if (!hasRoom(bi, x, y)) {								setUp(false);								end = true;								repaint();							}						}						after = System.currentTimeMillis();						sleep = delay - (after - before);						sleep = sleep < 0 ? delay : sleep;						try {							Thread.sleep(sleep);						} catch (InterruptedException ignore) {						}					}				} catch (Throwable ex) {					ex.printStackTrace();				}			}