gpt4 book ai didi

java - Java 应用程序在 Linux 上的挂起

转载 作者:太空狗 更新时间:2023-10-29 12:04:02 25 4
gpt4 key购买 nike

我在 linux 上运行我的应用程序,有时它会挂起。

请帮助我理解它挂起的原因。请在下面找到调用堆栈。我以为 jvm 有问题。

user@ubuntu:~$ sudo /usr/lib/jvm/jdk1.7.0/bin/jstack -F 14429
Attaching to process ID 14429, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 23.25-b01
Deadlock Detection:

No deadlocks found.

Thread 14430: (state = BLOCKED)


Thread 14698: (state = IN_NATIVE)
- java.io.FileInputStream.readBytes(byte[], int, int) @bci=0 (Interpreted frame)
- java.io.FileInputStream.read(byte[], int, int) @bci=4, line=242 (Interpreted frame)
- java.io.BufferedInputStream.fill() @bci=175, line=235 (Interpreted frame)
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=275 (Interpreted frame)
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=334 (Interpreted frame)
- java.io.FilterInputStream.read(byte[]) @bci=5, line=107 (Interpreted frame)
- org.apache.commons.exec.StreamPumper.run() @bci=31, line=105 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)


Thread 14697: (state = IN_NATIVE)
- java.io.FileInputStream.readBytes(byte[], int, int) @bci=0 (Interpreted frame)
- java.io.FileInputStream.read(byte[], int, int) @bci=4, line=242 (Interpreted frame)
- java.io.BufferedInputStream.fill() @bci=175, line=235 (Interpreted frame)
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=275 (Interpreted frame)
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=334 (Interpreted frame)
- java.io.FilterInputStream.read(byte[]) @bci=5, line=107 (Interpreted frame)
- org.apache.commons.exec.StreamPumper.run() @bci=31, line=105 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)


Thread 14695: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.lang.UNIXProcess.waitFor() @bci=8, line=210 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor.executeInternal(org.apache.commons.exec.CommandLine, java.util.Map, java.io.File, org.apache.commons.exec.ExecuteStreamHandler) @bci=106, line=347 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor.access$200(org.apache.commons.exec.DefaultExecutor, org.apache.commons.exec.CommandLine, java.util.Map, java.io.File, org.apache.commons.exec.ExecuteStreamHandler) @bci=6, line=46 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor$1.run() @bci=29, line=188 (Interpreted frame)


Thread 14621: (state = IN_NATIVE)
- java.lang.UNIXProcess.waitForProcessExit(int) @bci=0 (Interpreted frame)
- java.lang.UNIXProcess.access$200(java.lang.UNIXProcess, int) @bci=2, line=54 (Interpreted frame)
- java.lang.UNIXProcess$3.run() @bci=11, line=174 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)


Thread 14496: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.util.TimerThread.mainLoop() @bci=28, line=526 (Interpreted frame)
- java.util.TimerThread.run() @bci=1, line=505 (Interpreted frame)

Thread 14464: (state = BLOCKED)


Thread 14454: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=44, line=135 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove() @bci=2, line=151 (Interpreted frame)
- java.lang.ref.Finalizer$FinalizerThread.run() @bci=16, line=189 (Interpreted frame)


Thread 14453: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.lang.ref.Reference$ReferenceHandler.run() @bci=46, line=133 (Interpreted frame)

最佳答案

正如 Peter Lawrey 所说,您似乎被代码中的 waitFor() 调用阻塞了。

也许您正在从进程 STDOUTPUT 而不是从 STDERROR 读取...看看这个古老的 SO 帖子 Capturing stdout when calling Runtime.exec

编辑:如果您在代码中使用 ProcessBuilder,请尝试

yourProcessBuilder.redirectErrorStream(true);

关于java - Java 应用程序在 Linux 上的挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21496214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com