Wait for all threads to finish before proceeding

Godot Version

4.6

Question

If I spawn multiple threads to do various processing such as resource loading, scene runtime preparation, etc., is it possible to have a function be invoked when all threads have finished successfully?

Set a counter to the number of launched threads, decrement it by one when each thread finishes. When the counter reaches zero - all threads are finished.