Is KotlinJsr223JvmLocalScriptEngine thread-safe? I...
# scripting
i
Is KotlinJsr223JvmLocalScriptEngine thread-safe? I'd like to use it like this:
Copy code
suspend override fun <T> execute(inputStream: InputStream): T {
        // ToDo: Is scriptEngine thread safe?
        return CompletableFuture.supplyAsync { scriptEngine.eval(inputStream.reader()) as T }.await()
    }
i
irus: This is the grey zone. Most important parts are internally synchronized, but this is not thoroughly tested on the thread-safety as a whole. There is also a logical synchronization issues, since the engine stores the compilation and evaluation history, and items from the different threads may logically conflict. I’d recommend to use one engine per (logical) evaluation thread.
i
Okay, thanks for advice