All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.java.lang.Thread.kt Maven / Gradle / Ivy

package name.remal

import java.lang.Thread.currentThread

inline fun  forThreadContextClassLoader(contextClassLoader: ClassLoader?, action: () -> R): R {
    val currentThread = currentThread()
    val prevContextClassLoader = currentThread.contextClassLoader
    currentThread.contextClassLoader = contextClassLoader
    try {
        return action()

    } finally {
        currentThread.contextClassLoader = prevContextClassLoader
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy