Last Updated: February 25, 2016
·
2.125K
· davetron5000

Threads in Ruby? Use JRuby

Threads are an easy way to run background processes or do things concurrently, but the management of threads and shared state can be difficult.

Use JRuby and the java.util.concurrent package. The javadoc is amazing:

http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html

And with JRuby, you can write idiomatic Ruby code that uses all the power provided by the JVM for managing threads and dealing with shared state.