if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { 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) {
if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { 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++; SwingUtilities.invokeLater(runRepaint); } else { newBlock(); if (!hasRoom(bi, x, y)) { setUp(false); end = true; SwingUtilities.invokeLater(runRepaint); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) {
	public void newGame() {        setUp(false);        if (thread != null) {			if (pause) {				flipPause();			}			try {				thread.join();			} catch (InterruptedException ignore) {			}		}		for (int i = 0; i < WIDTH_C + 2; i++) {			for (int j = 0; j < HEIGHT_C + 2; j++) {				if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1)					WORLD[i][j] = COLORS.length - 1;				else					WORLD[i][j] = 0;			}		}		requestFocus();		end = false;		score = 0;		si = si_rnd.nextInt(7);		next_si = si_rnd.nextInt(7);		bi = bi_rnd.nextInt(4);		next_bi = bi_rnd.nextInt(4);		x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0]));		y = 0;		thread = new Thread(new Runnable() {			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();				}			}		});        setUp(true);        thread.start();	}