程序运行3天,出现java.util.NoSuchElementException异常
[code="java"]
java.util.NoSuchElementException
at java.util.LinkedList.remove(LinkedList.java:788)
at java.util.LinkedList.removeFirst(LinkedList.java:134)
at java.util.LinkedList.poll(LinkedList.java:470)
at com.etopad.netunion.visitorInfo.quartz.SaveVisitorInfoJob.pollWm(SaveVisitorInfoJob.java:118)
at com.etopad.netunion.visitorInfo.quartz.SaveVisitorInfoJob.executeInternal(SaveVisitorInfoJob.java:70)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:531)
[/code]
[code="java"]
if (visitorsNum != 0) {
for (int i = 0; i < visitorsNum; i++) {
saveWmList.add(wmVisitors.poll());
}
}
[/code]
我用poll(),就算LinkedList链表中没数据也是输出null的啊,不会出现java.util.NoSuchElementException异常,程序跑了3天后才出现这个问题的,请问是什么原因?