java - Using less Timers -


it doesn't lag in game know reduce lot of lag in game having less timer's running. game have multiple timer's because have 1 timer updates players location , obstacles have other timer's use remove power ups get.

for example have 1 timer have it's initial delay set 5000 , when runned 1 time (it run 1 time) remove specific power , have timer have it's initial delay set 20 000. how keep different delay of each timer still using 1 or @ least fever use now?

is there anyway use priorityqueue or scheduledthreadpoolexecutor accomplish this? , if how?

you schedule tasks on scheduledthreadpoolexecutor, , re-schedule them different delay if want run same task again.

another option use delayqueue store tasks want execute, , use separate thread take , execute runnables off of queue. scheduledthreadpoolexecutor you'd have put runnables on queue new delay if want them run again.

the scheduledthreadpoolexecutor lets schedule tasks continually run after fixed delay, whereas delayqueue requires keep putting task on queue after it's run.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -