/* Author: Jeff Dalton * Updated: Sun May 6 22:00:16 2001 by Jeff Dalton * Copyright: (c) 2001, AIAI, University of Edinburgh */ package ix.util.context; import java.util.*; /** * A context-holding strategy that associates context-holders with * threads. The holder for a thread is initially null and so must * be explicitly set. More than one thread may be given the same * context-holder. */ public class ThreadLocalHoldingStrategy extends ContextHoldingStrategy { ThreadLocal threadContextHolder; public ThreadLocalHoldingStrategy() { threadContextHolder = new ThreadLocal(); } public ContextHolder getContextHolder() { return (ContextHolder)threadContextHolder.get(); } public void setContextHolder(ContextHolder h) { threadContextHolder.set(h); } }