JAvaマルチスレッドの使用


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();
	}
	
}