此为jmf视频传输模块中的一部分,其他地方没问题,问题就出在while循环里:
JVM崩溃:我测试过了,运行到while 里面才崩溃的。 getState()函数返回一个整形 private synchronized boolean waitForState(Processor p, int state) {
p.addControllerListener(new StateListener()); // 为处理器加上状态监听
failed = false; if (state == Processor.Configured) { // 配置处理器
p.configure();
}
else if (state == Processor.Realized) { // 实现处理器
p.realize();
} // 一直等待,直到成功达到所需状态,或失败
while (p.getState() < state && !failed) {
synchronized (getStateLock()) {
try {
getStateLock().wait();
}
catch (InterruptedException ie) {
return false;
}
}
}
/**
* 内部类:处理器的状态监听器
* */
class StateListener implements ControllerListener {
public void controllerUpdate(ControllerEvent ce) {
// 假如在处理器配置或实现过程中出现错误,它将关闭
if (ce instanceof ControllerClosedEvent) // 控制器关闭
setFailed(); // 对于所有的控制器事件,通知在waitForState方法中等待的线程
if (ce instanceof ControllerEvent) {
synchronized (getStateLock()) {
getStateLock().notifyAll();
}
}
}
}
这是崩溃时控制台提示的信息。
Track 0 is set to transmit as:
dvi/rtp, 22050.0 Hz, 4-bit, Mono
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (0xe06d7363), pid=2732, tid=2600
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode, sharing windows-x86)
# Problematic frame:
# C [kernel32.dll 0x12a5b]
#
# An error report file with more information is saved as:
# D:\Studio\eclipse\workspace\test\hs_err_pid2732.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
JVM崩溃:我测试过了,运行到while 里面才崩溃的。 getState()函数返回一个整形 private synchronized boolean waitForState(Processor p, int state) {
p.addControllerListener(new StateListener()); // 为处理器加上状态监听
failed = false; if (state == Processor.Configured) { // 配置处理器
p.configure();
}
else if (state == Processor.Realized) { // 实现处理器
p.realize();
} // 一直等待,直到成功达到所需状态,或失败
while (p.getState() < state && !failed) {
synchronized (getStateLock()) {
try {
getStateLock().wait();
}
catch (InterruptedException ie) {
return false;
}
}
}
/**
* 内部类:处理器的状态监听器
* */
class StateListener implements ControllerListener {
public void controllerUpdate(ControllerEvent ce) {
// 假如在处理器配置或实现过程中出现错误,它将关闭
if (ce instanceof ControllerClosedEvent) // 控制器关闭
setFailed(); // 对于所有的控制器事件,通知在waitForState方法中等待的线程
if (ce instanceof ControllerEvent) {
synchronized (getStateLock()) {
getStateLock().notifyAll();
}
}
}
}
这是崩溃时控制台提示的信息。
Track 0 is set to transmit as:
dvi/rtp, 22050.0 Hz, 4-bit, Mono
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (0xe06d7363), pid=2732, tid=2600
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode, sharing windows-x86)
# Problematic frame:
# C [kernel32.dll 0x12a5b]
#
# An error report file with more information is saved as:
# D:\Studio\eclipse\workspace\test\hs_err_pid2732.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
# D:\Studio\eclipse\workspace\test\hs_err_pid2732.log 看下你的日志吧
failed = false; if (state == Processor.Configured) { // 配置处理器
p.configure();
}
else if (state == Processor.Realized) { // 实现处理器
p.realize();
} // 一直等待,直到成功达到所需状态,或失败
while (p.getState() < state && !failed) {
synchronized (getStateLock()) {
try {
getStateLock().wait();
}
catch (InterruptedException ie) {
return false;
}
}
}
while (p.getState() < state && !failed) {
这是死循环 里面没有动态改变state的值 那个!failed感觉也没任何意义 前面已经定义为false后面也没有看到有啥用处。