`GC.gc` thread-safety?

Is calling GC.gc() concurrently from multiple threads allowed? How about GC.gc(false)?

I know the GC is stop-the-world, so doing that would diminish parallelism, I just want to know whether it’s correct to do so.

This will be threadsafe. Running GC already stops all other threads, so it has the necessary barriers already.

3 Likes