I tried to store my starting Thread in a ListArray
but this results in ConcurrentModificationExeption
. Can anybody help?
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
getData(parameters);
}
};
ArrayList<TimerTask> threadList = Threads.getInstance();
if(!threadList.isEmpty()){
for (Iterator<TimerTask> it = threadList.iterator(); it.hasNext(); ) {
TimerTask timerT = it.next();
boolean found = false;
if (timerTask.equals(timerT)){
found = true;
}
if(!found){
threadList.add(timerTask);
Timer timer = new Timer();
timer.scheduleAtFixedRate(timerTask, 0, 10000);
}
}
}else{
threadList.add(timerTask);
Timer timer = new Timer();
timer.scheduleAtFixedRate(timerTask, 0, 10000);
}