changeset 2:03fa40193abe

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 09 Dec 2009 12:04:36 +0900
parents 761beb884f91
children 595de657cbaf
files src/threadTest/Client.java src/threadTest/Server.java src/threadTest/TestThread.java
diffstat 3 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/threadTest/Client.java	Tue Dec 16 14:24:33 2008 +0900
+++ b/src/threadTest/Client.java	Wed Dec 09 12:04:36 2009 +0900
@@ -8,6 +8,8 @@
 	}
 	
 	public void run() {
+	    //for(int i=0; i< 10; i++) {
 		server.work();
+	    //}
 	}
 }
--- a/src/threadTest/Server.java	Tue Dec 16 14:24:33 2008 +0900
+++ b/src/threadTest/Server.java	Wed Dec 09 12:04:36 2009 +0900
@@ -4,8 +4,11 @@
 	int count = 0;
 	
 	void work() {
-		System.err.println("server-enter: count="+count);
+		// System.err.println("server-enter: count="+count);
 		count++;
-		System.err.println("server-leave: count="+count);
+		// System.err.println("server-leave: count="+count);
 	}
+
+	void set_count(int i) { count = i; }
+	int count() { return count ; }
 }
--- a/src/threadTest/TestThread.java	Tue Dec 16 14:24:33 2008 +0900
+++ b/src/threadTest/TestThread.java	Wed Dec 09 12:04:36 2009 +0900
@@ -2,21 +2,33 @@
 
 public class TestThread {
 	Server t1 = new Server();
-	Client t2 = new Client(t1);
-	Client t3 = new Client(t1);
+	Client t2 ;
+	Client t3 ;
+	// Client t4 ;
 	
 	public static void main(String arg[]) throws InterruptedException  {
 		TestThread test = new TestThread();
-		test.test();
+		//for(int i=0; i<1000; i++) {
+		    test.test();
+		//}
 	}
 	
 	public void test() throws InterruptedException {
+		t2 = new Client(t1);
+		t3 = new Client(t1);
+		// t4 = new Client(t1);
+
+		int s = t1.count();
+
 		t2.start();
 		t3.start();
+		// t4.start();
 		t2.join();
 		t3.join();
+		// t4.join();
+		assert( t1.count() == s + 2);
 
-		System.err.println("testThread: count = "+t1.count);
+		// System.err.println("testThread: count = "+t1.count);
 	}
 
 }