1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core.util;
13 import java.util.Hashtable;
16 * Implementation of data structure remembering an Object value by thread. Its purpose is to ease
17 * writing multi-threaded algorithms by providing a per thread data structure.
19 public class PerThreadObject {
21 private Hashtable internalMap = new Hashtable(3); // synchronized map
24 * Answer the current map for this thread
26 public Object getCurrent(){
27 return this.internalMap.get(Thread.currentThread());
31 * Set the map for this current thread - setting to null is equivalent to removing it
33 public void setCurrent(Object current){
35 this.internalMap.remove(Thread.currentThread());
37 this.internalMap.put(Thread.currentThread(), current);