mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-05-24 10:14:10 +00:00
Merge pull request #2189 from Fox2Code/1.4.7-concurrent-fix
Fix ConcurrentModificationException caused by timers
This commit is contained in:
commit
fc66d15012
@ -203,8 +203,10 @@ public class OSAPI implements ILuaAPI {
|
|||||||
*/
|
*/
|
||||||
@LuaFunction
|
@LuaFunction
|
||||||
public final int startTimer(double timer) throws LuaException {
|
public final int startTimer(double timer) throws LuaException {
|
||||||
timers.put(nextTimerToken, new Timer((int) Math.round(checkFinite(0, timer) / 0.05)));
|
synchronized (timers) {
|
||||||
return nextTimerToken++;
|
timers.put(nextTimerToken, new Timer((int) Math.round(checkFinite(0, timer) / 0.05)));
|
||||||
|
return nextTimerToken++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,7 +219,9 @@ public class OSAPI implements ILuaAPI {
|
|||||||
*/
|
*/
|
||||||
@LuaFunction
|
@LuaFunction
|
||||||
public final void cancelTimer(int token) {
|
public final void cancelTimer(int token) {
|
||||||
timers.remove(token);
|
synchronized (timers) {
|
||||||
|
timers.remove(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user