I love DelayedJob. It's my go-to-gem for background processing in Rails, mainly because it works with whatever data store your project already has in place. No need to bring a different dependency just for background processing. However, using Delayed::Worker in threads is problematic.
The jRubyWorker inherits most of it's behavior from Delayed::Worker, but leverages some specifics of the JVM and makes some accommodations for threads instead of processes.
(The above code is simplified a bit for illustration purposes. Any exception thrown in the worker connecting to the database would otherwise kill the thread silently. I added some code to harden the thread and restart dead workers).
At some point, we decided to leverage DelayedJob's support for named queues to better split up the workload.
My expectation is that I would have one worker dedicated to jobs in the main queue and another worker for events. In reality, what we had was two workers for events and an ever-growing main queue.
Initializing an instance of Worker sets options, not on that instance, but for ALL instances. The dreaded global state that is the source of so many problems while working with threads.
To be fair, it is clear from the rest of the DelayedJob model that the assumption is that workers will run in a separate process than the rest of the application. That is why jRubyWorker has to change the way the worker defines it's name. Worker assumes that using the process id will give you uniqueness. In a threading model, it obviously won't.
My first instinct was to just make the options a property of each worker. However, it's not that easy: DelayedJob has several different back-ends (For ActiveRecord, MongoMapper, etc). Each of those need to be changed, because they read the options from the Worker class and not the instance.
I believe that there is nothing fundamentally wrong with DelayedJob and it could certainly be made to work with threads be removing the global state. However, it would break compatibility with existing back-end implementations, so it's a little bit more involved than a pull request. I tried contacting the authors on the mailing list, but so far it looks like my post has not been approved by the moderator.