Your suspicions are correct:  an interceptor may be invoked by several
threads concurrently.  For instance:

class TimingInterceptor implements MethodInterceptor {
  private final Stopwatch stopwatch;

   TimingInterceptor(Stopwatch stopwatch) {
       this.stopwatch = stopwatch;
    }

  @Override Object invoke(MethodInvocation i) throws Throwable {
       stopwatch.reset();
       try {
         return i.proceed();
       } finally {
          System.err.println("Invocation time: " + stopwatch.get());
      }
  }

Is going to break, because the stopwatch is shared among threads.

-Fred

On Mon, Jan 24, 2011 at 9:46 AM, Anthony MULLER <[email protected]>wrote:

> Hello,
>
> I'm using "method interceptor" mechanisms with Guice 1.0 and I wish to
> know if it is thread-safe? (I have some strange behaviours in
> multithreading environment)
>
> Regards,
> Anthony MÜLLER
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to