java

oλv 2025-02-04T11:57:58.999329Z

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.

oyakushev 2025-02-04T12:21:06.059839Z

Non-stopped threads are not garbage-collected in JVM.

Shantanu Kumar 2025-02-05T10:05:28.930349Z

@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-

oλv 2025-02-05T10:09:26.187849Z

TIL! Thanks

oλv 2025-02-05T10:11:30.820399Z

Some missing context: my goal is to write my own little JIT x64 assembler in Clojure and execute the resulting machine code in-process.

👍🏽 1
oλv 2025-02-05T10:11:44.215199Z

Purely for curiosity/fun purposes :^)

2025-02-05T13:38:22.010679Z

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.

2025-02-05T13:39:19.499669Z

I do not know if anyone has tried to create the native method code in-memory, and then invoke it from the same JVM.

souenzzo 2025-02-06T14:53:56.382909Z

JNI isn't the way to FFI Checkout "panama project" in JDK and #coffi for a wrapper for clojure 🙂

💯 3