G1 and other collectors (parallel) use sets of threads as workers (e.g. gc workers, refinement, marking).
Currently they are allocated upfront, except if -XX:+UseDynamicNumberOfGCThreads is used. In JDK-8190937 we would like to detach this lazy allocation from dynamically determining the number of gc threads.
Before that is done, it may be prudent to think and unify the behavior in exceptional cases when lazy allocating them.
Questions like:
- what happens if we can't allocate a thread (during initialization, at the time of use)
- is there a minimum number of threads in these sets that we absolutely need to operate?
- warning messages if any, should they be repeated?