view src/treecms/proto/test/UUIDTest.java @ 12:c8e31aaac297

added TestMultiThread1 , seems like java.util.UUID is not thread-safe
author shoshi
date Sun, 29 Aug 2010 00:11:08 +0900
parents
children 3bccd745f2e2
line wrap: on
line source

package treecms.proto.test;

import java.util.*;

public class UUIDTest extends Thread
{
	public static void main(String _args[])
	{
		Thread th1 = new UUIDTest();
		Thread th2 = new UUIDTest();
		Thread th3 = new UUIDTest();
		Thread th4 = new UUIDTest();
		
		th1.start();
		th2.start();
		th3.start();
		th4.start();
		
		try {
			th1.join();
			th2.join();
			th3.join();
			th4.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void run()
	{
		for(int i = 0;i < 3;i ++){
			try{
				System.out.println(UUID.randomUUID().toString());
			}catch(Exception _err){
				_err.printStackTrace();
			}
		}
	}
}