There is no reason to expect that distinct invocations use distinct threads.
The invocation entry point is responsible for establishing the thread
context. In this case the try{...} finally{...} of the JRMPInvoker has
to clear the thread locals if it wants to limit the context to the invocation
lifetime.

xxxxxxxxxxxxxxxxxxxxxxxx
Scott Stark
Chief Technology Officer
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx

----- Original Message -----
From: "Bill Burke" <[EMAIL PROTECTED]>
To: "Juha Lindfors" <[EMAIL PROTECTED]>; "Tom Elrod" <[EMAIL PROTECTED]>; 
"Jeff Haynie" <[EMAIL PROTECTED]>;
"Scott. Stark@Jboss. Org" <[EMAIL PROTECTED]>; "Jboss-Dev" 
<[EMAIL PROTECTED]>
Sent: Wednesday, January 15, 2003 8:34 PM
Subject: [JBoss-dev] ThreadPooling in JMX? Its broken


> Ok, I was doing some coding and found that my ThreadLocal variable was the
> same even between remote MBean invocations.  Is there some ThreadPooling
> going on that is not releasing the ThreadLocal variables?
>
> TESTCASE:
>
> 1. remotely invoke on method test1 - this sets testit ThreadLocal variable
> to "hello"
> 2. return from remote invocation
> 3. remotey invoke on method test2 - this just prints out value of testit
> ThreadLocal variable.  It will still be hello!
>
> How the hell can you clear ThreadLocal variables if you are thread pooling?
> I'm using the RMI Connector to invoke on my MBean.
>
> Thanks,
>
> Bill
>
>
>
> import javax.management.MBeanRegistration;
> import javax.management.MBeanServer;
> import javax.management.ObjectInstance;
> import javax.management.ObjectName;
> import org.jboss.logging.Logger;
> import org.jboss.system.ServiceMBeanSupport;
>
> public class ThreadLocalTester
>    extends ServiceMBeanSupport
>    implements ThreadLocalTesterMBean, MBeanRegistration
> {
>    // Constants ----------------------------------------------------
>    // Attributes ---------------------------------------------------
>    static Logger log = Logger.getLogger(AOPTester.class);
>    MBeanServer m_mbeanServer;
>    ThreadLocal testit = new ThreadLocal();
>
>    // Static -------------------------------------------------------
>
>    // Constructors -------------------------------------------------
>    public ThreadLocalTester()
>    {}
>
>    // Public -------------------------------------------------------
>
>    // MBeanRegistration implementation -----------------------------------
>    public ObjectName preRegister(MBeanServer server, ObjectName name)
>    throws Exception
>    {
>       m_mbeanServer = server;
>       return name;
>    }
>
>    public void postRegister(Boolean registrationDone)
>    {}
>    public void preDeregister() throws Exception
>    {}
>    public void postDeregister()
>    {}
>
>    protected void startService()
>       throws Exception
>    {
>    }
>
>    protected void stopService() {}
>
>
>    public void test1()
>    {
>       testit.set("hello");
>    }
>
>    public void test2()
>    {
>       System.out.println(testit.get());
>    }
>
>    // Inner classes -------------------------------------------------
> }



-------------------------------------------------------
This SF.NET email is sponsored by: A Thawte Code Signing Certificate 
is essential in establishing user confidence by providing assurance of 
authenticity and code integrity. Download our Free Code Signing guide:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to