Joseph Mok wrote:
>
> Hi
>
> Can anyone briefly describe how concurrency is handled by the interceptors
> or the container containing the interceptors? Here's a specific scenario
> relating to LogInterceptor.
>
> I've looked through the logging components and got a good idea of how they
> call one another. However, I don't understand how "thread-safeness" occurs
> in the method invoke(MethodInvocation) in LogInterceptor. There's a call to
> Log.set(log), which pushes the local instance of Log onto the Log stack.
> Then the work is done and the method ends with Log.unsetLog(). What if in
> between the two calls, another component (or instance of LogInterceptor?)
> pushes another instance of Log onto the stack, given that the stack in Log
> is a static instance. Wouldn't that cause a problem then? I assume the
> container prevents this somehow. Does anyone know how the "somehow" is done?
The Log stack is a static ThreadLocal, which means each Thread has its
own stack of Logs.
See Log.java:36
Sebastien
> Thanks
>
> Joseph
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]