sandbox world Dynamic generation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kyla

My project has 1010chunk
32
32+3232 staticbody2d in each chunk
3
3 chunks around the player will be dynamically generated
Whenever the player moves, the dynamic add_child (the chunk to be added) and remove_chind (the excess chunk)
Now I am experiencing a performance problem
Because of thread safety issues, help thread cannot add_child
I can only add_child() in the main thread, and add_child() in the main thread will cause the game to get stuck for 0.x seconds, making the game not smooth.
How to solve