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


After

I have somehow been called Thread.interrupt () , which is the thread of logging For the purpose of logging information (and its current stack), the call has been issued to identify which thread is being interrupted.

Is there any way to do this? Looking for the information, I referred to the possibility of someone applying a security manager. Is it something that can be done during runtime (for example, in an applet or webstart client), or do you have to do this?

Is the JVM device installed or is there a better way to do this?

After

very

as a quick hack, it was easy to do Thought it would be. Since this is a quick hack, I did not do things like ensuring that the stack trace is quite deep, before the reference to the array, etc. I put the following in the manufacturer of my signed applet:

  log .info ("old security manager =" + System.getSecurityManager ()); System.setSecurityManager (New SecurityManager) {@Override Public Zero CheckAccess (Final Thread T) {StackTraceElement [list] = Thread.currentThread () getStackTrace ();. StackTraceElement element = List [3]; if (element.getMethodName () .equals ("middle")) {log.info ("To disrupt CheckAccess (Thread =" + t.getName (+) "") - "+ element.getMethodName ()); dumpThreadStack (Thread.currentThread () );} Super.checkAccess (t);}});  

and dumpThreadStack the method is as follows:

  Public static zero-free thread stack {Last thread thread} {StringBuilder builder = New StringBuilder ('\ n'); Try {for (StackTraceElement element: thread.getStackTrace ()) {builder.append (element.toString ()). Enclosed ('\ n'); }} Grip (Security Exception e) {/ * unseen log.info (builder.stistance ()); }  

I could never leave it in the output code, but it was enough to tell me which thread generated a interrupt () It was not expected that, with this code, I would like to Thread.interrupt () .

gets a stack dump for each call,

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -