Hi everyone, we’re in the process of making a game and a question has come up to mind.
The scenario it’s like this, in a moment of the game we have houses that may be hit with fireballs, the behaviour expected it’s that the fireball does damage to the house in a period of time (like the house gets burning for 3 seconds, taking damage every second). Now what we’ve thinking to do this it’s that when a fireball hits a house, a damageTimer it’s created making the house take damage every second.
The questions begins when we imagine a scenario when a house gets hit by a fireball first and in a moment later (soon) gets hit by another fireball, before the first one dies (stop burning the house and disappear) the question it’s what would happen with concurrency issues, at that moment we’ll have two timers that will be operating with the same variable (houseHealth = houseHealth - damageByFireball). As you can see there maybe times when concurrency problems could present by the N timers because they’re dealing with the same shared variable…so is there actually concurrency issues being present with timers? or they just simply simulate concurrency but in the reality there’s no actually two timers being “processed” at the same time? if not, is there any way we could protect our shared variable?
Thanks a lot for any response!
[import]uid: 57552 topic_id: 25917 reply_id: 325917[/import]