KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > util > ThreadLocalLong


1 /*
2  * ThreadLocalLong.java
3  *
4  * Created on 25. Juli 2006, 13:39
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.util;
23
24 /**
25  * A long which's value is local to each thread.
26  * Its initial value is <code>0</code>.
27  *
28  * @author Christian Schlichtherle
29  * @version @version@
30  * @since TrueZIP 6.2
31  */

32 public class ThreadLocalLong extends ThreadLocal JavaDoc {
33
34     public final long getValue() {
35         return ((Holder) get()).value;
36     }
37
38     public final void setValue(long value) {
39         ((Holder) get()).value = value;
40     }
41
42     protected final Object JavaDoc initialValue() {
43         return new Holder();
44     }
45
46     private final static class Holder {
47         long value;
48     }
49 }
Popular Tags