此为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. 

解决方案 »

  1.   

    如果楼主是想查看内存状态的话,建议你看一下JPF的源码,它里面实现了一个简单的JVM,包含了大量的内存跟踪操作。# An error report file with more information is saved as: 
    # D:\Studio\eclipse\workspace\test\hs_err_pid2732.log  看下你的日志吧
      

  2.   

    jvm崩溃可能是死循环,你看看p.getState() < state && !failed这个条件,有跳出循环的时候吗
      

  3.   


    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后面也没有看到有啥用处。
      

  4.   

    多线程共享标志位failed,最好用volatile修饰下
      

  5.   

    楼楼上的,另外一个线程里调用setFailed()函数里会设置fail为true的吧
      

  6.   

    是的,setFailed()函数里会设置fail为true
      

  7.   

    while()不是死循环,现在的问题是在有些电脑上会崩溃,在有些电脑上可以正常运行,所以我怀疑此问题与windows有关,不知是否如此
      

  8.   

    我现在发现,问题是p.realize()一直无法达到Processor.Realized(即300),所以导致阻塞崩溃