Java thread dump evaluation

I have a thread dump of one of my processes. It has a bunch of these threads. I assume they store a bunch of memory, so I get OOM.

"Thread-8264" prio=6 tid=0x4c94ac00 nid=0xf3c runnable [0x4fe7f000]
   java.lang.Thread.State: RUNNABLE
    at java.util.zip.Inflater.inflateBytes(Native Method)
    at java.util.zip.Inflater.inflate(Inflater.java:223)
    - locked <0x0c9bc640> (a java.util.zip.Inflater)
    at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:235)
    at com.my.ZipExtractorCommonsCompress.extract(ZipExtractorCommonsCompress.java:48)
    at com.my.CustomThreadedExtractorWrapper$ExtractionThread.run(CustomThreadedExtractorWrapper.java:151)

   Locked ownable synchronizers:
    - None

"Thread-8241" prio=6 tid=0x4c94a400 nid=0xb8c runnable [0x4faef000]
   java.lang.Thread.State: RUNNABLE
    at java.util.zip.Inflater.inflateBytes(Native Method)
    at java.util.zip.Inflater.inflate(Inflater.java:223)
    - locked <0x0c36b808> (a java.util.zip.Inflater)
    at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:235)
    at com.my.ZipExtractorCommonsCompress.extract(ZipExtractorCommonsCompress.java:48)
    at com.my.CustomThreadedExtractorWrapper$ExtractionThread.run(CustomThreadedExtractorWrapper.java:151)

   Locked ownable synchronizers:
    - None

I am trying to figure out how this happened in this situation. CustomThreadedExtractorWrapper is a wrapper class that launches a thread to do some work (ExtractionThread, which uses ZipExtractorCommonsCompress to extract zip content from a compressed stream). If the task takes too much time, it is called to cancel the operation ExtractionThread.interrupt().

In my magazines, I see that the cancellation happened 25 times. And I see 21 of these streams in my landfill. My questions:

  • What is the status of these threads? Alive and running? Blocked?
  • They did not die with .interrupt (), apparently? Is there a surefire way to really kill a thread?
  • "" ?

223 Inflater.java:

public synchronized int inflate(byte[] b, int off, int len) {
    ...
    //return is line 223
    return inflateBytes(b, off, len);                          
}
+3
4

"" , ; , synchronized, , .

Thread.stop(), , , . . , , , , .

Thread.interrupt() . , , - (I/O, wait()). .

"runnable": . Inflater.inflate() ; . (Inflater.inflateBytes(), , Zlib, ). , (, ZipExtractorCommonsCompress) , Zip , , .

+3
  • runnable

  • ... , , , sleep, wait InteruptedException . interuption isInterupted()

  • locked ,

+2

, jvisualvm ( bin JDK). Java (, ..). , . :

Thread.State API:

NEW - A thread that has not yet started is in this state.
RUNNABLE - A thread executing in the Java virtual machine is in this state.
BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
WAITING - A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
TIMED_WAITING - A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
TERMINATED - A thread that has exited is in this state.

, , ( runnable , , , , , ).

"" :

  • call Thread stop()
  • , ( run()).

, , , , .

0

?

, .

Thread.interrupt(), , , .

Thread.stop(), , . , Thread.stop() , , - , , , , . , , stop(), () notify() , . , ( ) ThreadDeath, stop() .

, Thread.stop() - .

0

Source: https://habr.com/ru/post/1739139/


All Articles