ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ThreadLocalTest.java
Revision: 1.4
Committed: Sat Dec 27 19:26:44 2003 UTC (20 years, 4 months ago) by dl
Branch: MAIN
Changes since 1.3: +5 -4 lines
Log Message:
Headers reference Creative Commons

File Contents

# Content
1 /*
2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/licenses/publicdomain
5 * Other contributors include Andrew Wright, Jeffrey Hayes,
6 * Pat Fisher, Mike Judd.
7 */
8
9 import junit.framework.*;
10 import java.util.concurrent.Semaphore;
11
12 public class ThreadLocalTest extends JSR166TestCase {
13 public static void main(String[] args) {
14 junit.textui.TestRunner.run(suite());
15 }
16
17 public static Test suite() {
18 return new TestSuite(ThreadLocalTest.class);
19 }
20
21 static ThreadLocal tl = new ThreadLocal() {
22 public Object initialValue() {
23 return new Integer(1);
24 }
25 };
26
27
28 /**
29 * remove causes next access to return initial value
30 */
31 public void testRemove() {
32 Integer one = new Integer(1);
33 Integer two = new Integer(2);
34 assertEquals(tl.get(), one);
35 tl.set(two);
36 assertEquals(tl.get(), two);
37 tl.remove();
38 assertEquals(tl.get(), one);
39 }
40 }
41