我正在尝试通过调用
将数据写入ObservableList<Packet> iplt_data = FXCollections.observableArrayList()
Platform.runLater(() -> iplt_data.addAll(Start.packets.subList(lastInsertedPacket, indexAmmount)) );
但是获得并发修改异常:
Exception in thread "JavaFX Application Thread" java.util.ConcurrentModificationException
at java.util.ArrayList$SubList.checkForComodification(ArrayList.java:1231)
at java.util.ArrayList$SubList.listIterator(ArrayList.java:1091)
at java.util.AbstractList.listIterator(AbstractList.java:299)
at java.util.ArrayList$SubList.iterator(ArrayList.java:1087)
at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
at javafx.collections.ModifiableObservableListBase.addAll(ModifiableObservableListBase.java:99)
at controller.Network.lambda$3(Network.java:205)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
但是,如果我从Platform.runLater
中取出该功能,它可以正常工作并将数据添加到表中:
iplt_data.addAll(Start.packets.subList(lastInsertedPacket, indexAmmount));
我在其他表上使用了相同的Platform.runLater
调用,它运行正常,这可能是什么问题?