This may be a somewhat...unorthodox question. I have multiple apps running in the same JVM, each in their own classloader. These apps need to communicate with eachother (only a little bit though), but I can't add shared code of my own to a classloader these apps share, so I need to do it with facilities provided by the standard Java runtime.
I thought along the lines of using System
properties. However, it'd be hard to make thread-safe, though I suppose I could use synchronized
on an interned long random String.
Any more options?
The communication I want goes as follows. This may affect the suitable options.
- Each app, in sequence, puts its name in a shared queue.
- Each app, at the same time, starts polling the queue to see whether its own name is at the head. If it is, it will perform a long running init task, then pull its name from the queue.