Is it possible to have an unmanaged thread in-process? By that I mean having a thread in-process which is ignored by the JVM, I.e not garbage collected or anything.
Non-stopped threads are not garbage-collected in JVM.
@post972 A regular thread prevents the JVM from exiting, but "Daemon threads" allow the JVM to exit (if that's what you mean by ignored-by-the-JVM): https://stackoverflow.com/a/2213348 and https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#setDaemon-boolean-
TIL! Thanks
Some missing context: my goal is to write my own little JIT x64 assembler in Clojure and execute the resulting machine code in-process.
Purely for curiosity/fun purposes :^)
You can definitely have Java threads that invoke methods with code written in other languages, via things like JNI (Java Native Interface). Such code can allocate memory that is not managed by the JVM's garbage collector.
I do not know if anyone has tried to create the native method code in-memory, and then invoke it from the same JVM.
JNI isn't the way to FFI Checkout "panama project" in JDK and #coffi for a wrapper for clojure 🙂