![](/img/trans.png)
[英]Beam TextIO write NullPointerException because destination is null
[英]NullPointerException because the Thread is null?
在過去的幾個月中,我現在已經三次收到該堆棧跟蹤信息。 只是以下三行:
java.lang.NullPointerException
at de.myapp.rec.MyThread.void run()(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
我想知道這是否意味着MyThread.run
方法為null
? 還是NullPointerException
有其他可能的原因?
線程通過啟動
myThread = new Thread(new MyThread());
Rec.threadWritingShouldContinue = true;
myThread.start();
線程的來源是關於:
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;
}
}
}
}
使用調試信息進行編譯將無濟於事,因為它可以持續數周才能再次看到它。
我想知道這是否意味着方法MyThread.run為空?
不能。方法不能為空。
還是NullPointerException有其他可能的原因?
只有一種可能的原因。 該代碼取消了對空指針的引用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.