Page 1 of 1

Schedule Task Error

Posted: 29 Jun 2013, 10:08
by jackygu
Hi, lapo,
I use schedule task as following:
mainExtension run a schedule task B_Extension, after B_Extension finish the task, call the mainExtension function: handleRequest(), the the following error happen.

jvm 1 | java.util.ConcurrentModificationException
jvm 1 | at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
jvm 1 | at java.util.LinkedList$ListItr.remove(Unknown Source)
jvm 1 | at it.gotoandplay.smartfoxserver.util.scheduling.Scheduler.executeTasks(Scheduler.java:327)
jvm 1 | at it.gotoandplay.smartfoxserver.util.scheduling.Scheduler.run(Scheduler.java:223)
jvm 1 | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
jvm 1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
jvm 1 | at java.lang.Thread.run(Unknown Source)

Pls inform how to solve, thanks.

jacky

Re: Schedule Task Error

Posted: 09 Jul 2013, 07:28
by Lapo
The problem is not with the Scheduler. You are modifying a LinkedList from two threads at the same time, which causes the data in the List to corrupt.
You will need to synchronize access between threads.
See here:
http://stackoverflow.com/questions/1241 ... linkedlist