FileDocCategorySizeDatePackage
ThreadLocalDemo.javaAPI DocExample3289Sun Feb 08 21:34:08 GMT 2004None

ThreadLocalDemo

public class ThreadLocalDemo extends Thread
Demonstrate use of ThreadLocal

Fields Summary
private static int
clientNum
A serial number for clients
private ThreadLocal
myClient
This ThreadLocal holds the Client reference for each Thread
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		Thread t1 = new ThreadLocalDemo();
		Thread t2 = new ThreadLocalDemo();
		t1.start();
		t2.start();
	
public voidrun()


	   
		System.out.println("Thread " + Thread.currentThread().getName() +
			" has client " + myClient.get());