Is there any way in Java to log *every* Thread interrupt?

前端 未结 5 808
清酒与你
清酒与你 2021-02-06 12:11

I would like to somehow log every time Thread.interrupt() is called, logging which Thread issued the call (and its current stack) as well as identifying information

5条回答
  •  不知归路
    2021-02-06 12:56

    I would look at AspectJ and its capabilities to wrap method calls. An execution pointcut around the interrupt() method should help here.

    Note that since you're looking to intercept a Java system method call (as opposed to your application code), the above may not be suitable. This thread seems to suggest it's possible, but note that he's created a woven rt.jar.

提交回复
热议问题