public class TestThread implements Runnable{
private int i = 0;
private int j = 0;
public void run() {
System.out.println(Thread.currentThread().getName()+"开始运行");
System.out.println(i + "+" + j + "=" + (i+j));
System.out.println(Thread.currentThread().getName()+"结束运行");
}
public void setI(int i) {
this.i = i;
}
public void setJ(int j) {
this.j = j;
}
public static void main(String[] args) throws Exception {
TestThread testThread = new TestThread();
testThread.setI(5);
testThread.setJ(10);
Thread t = new Thread(testThread,"测试线程");
t.start();
}
}