简体   繁体   English

NullPointerException因为线程为空?

[英]NullPointerException because the Thread is null?

I received this stack strace three times now during the last months. 在过去的几个月中,我现在已经三次收到该堆栈跟踪信息。 It's only these three lines: 只是以下三行:

java.lang.NullPointerException
    at de.myapp.rec.MyThread.void run()(Unknown Source)
    at java.lang.Thread.run(Thread.java:856)

I wonder if this could mean that the method MyThread.run got null ? 我想知道这是否意味着MyThread.run方法为null Or are there other possible reasons for the NullPointerException ? 还是NullPointerException有其他可能的原因?

The thread is started via 线程通过启动

myThread = new Thread(new MyThread());
Rec.threadWritingShouldContinue = true;
myThread.start();

The source of the thread is about that: 线程的来源是关于:

class MyThread implements Runnable
{
    @Override
    public void run() {
        while ( Rec.threadWritingShouldContinue ) {
            int bufferSize;

            /* Do some stuff with local variables
               ...
             */
            try {
                MyMain.fileIDwrite.write(Rec.bigBuffer, Rec.bigBufByteWritePtr, bufferSize);
            } catch ( IOException e ) {
                Rec.threadWritingShouldContinue = false;
            }
        }
    }
}

Compiling with debug information wont help as it can last weeks to see it again. 使用调试信息进行编译将无济于事,因为它可以持续数周才能再次看到它。

I wonder if this could mean that the method MyThread.run is null? 我想知道这是否意味着方法MyThread.run为空?

No. Methods cannot be null. 不能。方法不能为空。

Or are there other possible reasons for the NullPointerException? 还是NullPointerException有其他可能的原因?

There is only one possible reason. 只有一种可能的原因。 The code dereferenced a null pointer. 该代码取消了对空指针的引用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Beam TextIO写NullPointerException,因为目标为null - Beam TextIO write NullPointerException because destination is null Spark NullPointerException:无法调用 invalidateSerializedMapOutputStatusCache(),因为“shuffleStatus”是 null - Spark NullPointerException: Cannot invoke invalidateSerializedMapOutputStatusCache() because "shuffleStatus" is null 线程NullPointerException - Thread NullPointerException NullPointerException,在线程上 - NullPointerException, at thread 尽管执行null检查,但在多线程环境中仍获取NullPointerException - Getting NullPointerException in multi thread environment in spite of null check 应用程序因NullPointerException而崩溃 - Application crashing because of NullPointerException 获取 nullPointerException 因为 Mockito 变量设置为 null 即使我已经模拟了它 - Getting nullPointerException because Mockito variable is set to null even though I have mocked it java.lang.NullPointerException: org.openqa.selenium.OutputType)”,因为“screenShot”是 null - java.lang.NullPointerException : org.openqa.selenium.OutputType)" because "screenShot" is null Kafka Stream forward 方法抛出 NullPointerException 因为 ProcessorNode currentNode object 是 null - Kafka Stream forward method throwing NullPointerException because ProcessorNode currentNode object is null NullPointerException:无法调用 ServletRequestAttributes.getRequest,因为 RequestContextHolder.getRequestAttributes 的返回值为 null - NullPointerException: Cannot invoke ServletRequestAttributes.getRequest because the return value of RequestContextHolder.getRequestAttributes is null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM