Attempt to resolve a concurrent modification exception inside of DelayedExecutorService#onTick

This commit is contained in:
Aria 2023-05-08 06:09:09 -07:00
parent ab51609213
commit 8be88eedda
2 changed files with 13 additions and 10 deletions

View file

@ -12,7 +12,7 @@ plugins {
id 'maven-publish' id 'maven-publish'
} }
version = "1.1.9" version = "1.1.10"
group = "dev.zontreck" group = "dev.zontreck"
archivesBaseName = "LibAC" archivesBaseName = "LibAC"
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)

View file

@ -126,17 +126,20 @@ public class DelayedExecutorService {
DelayedExecutorService.stopRepeatingThread(); DelayedExecutorService.stopRepeatingThread();
} }
Iterator<DelayedExecution> it = EXECUTORS.iterator(); Iterator<DelayedExecution> it = EXECUTORS.iterator();
while(it.hasNext()) try{
{
DelayedExecution e = it.next(); while(it.hasNext())
if(e.unix_time < Instant.now().getEpochSecond())
{ {
it.remove(); DelayedExecution e = it.next();
Thread tx = new Thread(e.scheduled); if(e.unix_time < Instant.now().getEpochSecond())
tx.setName("DelayedExecutorTask-"+String.valueOf(DelayedExecutorService.getNext())); {
tx.start(); it.remove();
Thread tx = new Thread(e.scheduled);
tx.setName("DelayedExecutorTask-"+String.valueOf(DelayedExecutorService.getNext()));
tx.start();
}
} }
} }catch(Exception e){}
} }
public static int getNext() public static int getNext()