3 ms·
No. The JVM spins up several threads, even when running a single-threaded Java program. Threads and fork() do not mix well together, and using threads is heavil
by stephenjudkins 16y ago
No. The JVM spins up several threads, even when running a single-threaded Java program. Threads and fork() do not mix well together, and using threads is heavily entrenched in the Java world. I doubt Oracle intends to do the work to make fork() work.
As far as rewriting your code, would it be that difficult to change it to use threads? They don't FORCE you to share state, and there are powerful primitives for message-passing in java.util.concurrent. As long as you're not abusing global variables in Ruby it should translate over just fine.
- rbranson 16y agoI don't have a strong use-case for JRuby in this particular case, so I'll just continue to use YARV. There are some Java libraries I've been tempted to use, but it's not crucial at this point. It's not implementing message passing that's the problem, it's the shared state, multi-threaded model in general. It's too easy to trip up, so I prefer fork() and message-passing. I am less worried about my own code, but what future maintainers who have less experience in concurrent programming will have to deal with. It's just a framework for a pool of workers that hang off an MQ, so fork() also provides some extra resiliency in the event that something bad happens.
- bensummers 16y agoThere's nothing stopping you from running multiple JRuby instances, just as you would with any other interpreter, it's just you can't use fork() to create them. Use an external script/daemon to start up multiple processes. It's not as memory efficient as MRI, but isn't _too_ bad unless you're on a cheapo memory constrained VPS.