日期:2014-05-20 浏览次数:20735 次
package test;
import java.util.Scanner;
public class T4 extends Thread {
/**
* @param args
*/
public static void main(String[] args) {
T4 o = new T4();
o.start();
Scanner s = new Scanner(System.in);
String str;
while (true) {
str = s.next();
if (str.equals("1")) {
pause = true;
} else if (str.equals("0")) {
pause = false;
}
}
}
private boolean running = true;
private static boolean pause = false;
public void run() {
while (true) {
// 这里改造了一下
try {
Thread.sleep(150);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (pause) {
continue;
} else {
repaint();
}
}
}
void repaint() {
System.out.println("Painting...");
}
}