In containerized environments (Gradle build scripts, application containers, IDEA plugins), it is important to be able to unload the bundle of classes when the job is done.
Unfortunately, any code that touches our dispatchers (e.g. transitively, or via GlobalScope) cannot be unloaded: few indefinitely parked scheduler threads retain a strong reference to its class loader and cannot be terminated in any public way. For that, we should provide a public API to shutdown our dispatchers, destroy all their threads and make the outer classloader free.
The open question is how to establish a method contract in a way that nicely interacts with the fact that IO and Default are closely tightened and also take into account that depending on the system property, Dispatchers.Default can be backed by ForkJoinPool.commonPool that cannot be shut down (it doesn't suffer from this problem tho, because it's a JDK class that is always loaded by a bootstrap classloader).
The text was updated successfully, but these errors were encountered: