This will be threadsafe. Running GC already stops all other threads, so it has the necessary barriers already.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Is garbage collection thread safe? | 1 | 426 | August 7, 2018 | |
| Multithreaded GC? | 18 | 2647 | June 16, 2020 | |
| What's not threadsafe? | 11 | 1392 | May 18, 2018 | |
| Multithreaded program hangs without explict GC.gc() | 6 | 964 | July 20, 2023 | |
| Should I use multiple threads for parallel GC with otherwise sequential code? | 1 | 221 | February 5, 2024 |