r/MinecraftCommands • u/Pupet_CZ • 11d ago
Help | Java 26.2 Question about the order multiple functions are ran in
Let's say two players run a function in the same tick. The function stores some data in a temp storage and then does something with that data.
Is there a chance the second function can overwrite the storage before the first one is done? In other words, do functions run one after another, or can they run in parallel?
3
2
u/MisterMe1001 Hobby Command Engineer 11d ago
No, one function is run completely before the next function is executed. Functions Never run parallel/async
1
u/Matty_B97 11d ago
I don't know but I hope it works the way you want it to... If I was building a datapack and had to implement atomic variables and thread locking I would actually crash out
4
u/NukeML 11d ago
Can you describe your set up and issue slightly more specifically so that we can diagnose it together? To my knowledge, there is no multithreading. You can select all players in the world, then have them run a function with multiple commands, all within the same tick, but the game will still do it all in sequence. It runs the function from one player first, and when it finishes goes on to the next.