Posted November 14, 201410 yr I need to create a delayed explosion, but don't want to halt the execution of the main thread. I tried using java.util.Timer.schedule but ran into some concurrency issues (specifically IllegalStateExceptions). Does the world have a lock associated with it? If not, is there a better way to create a delayed explosion without stalling everything?
November 14, 201410 yr A generic tick handler. Every tick it can check and decrement timers for any 'delayed explosion entries'. Any that are supposed to explode can then be made to explode. Or, if you have a block, you can schedule a block event/callback. Or, if you have a tile-entity you can use internal varialbes/onUpdate code. Or, if you have an entity you can decrement a variable in the entity/onUpdate code. There is not necessarily a thread-lock, however there are multiple issues with trying to manipulate data across threads (cache coherency, stale data, yadda, etc... multiple books can and have been written on the subject). You can't just jump in and muck about with another threads data.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.