I am writing a multi-threaded solution in Java to connect two systems, A & B. System A is completly serial, not threaded, and will supply data to send to system B. System B accepts data from multiple sources asynchronously all at the same time.
I am using ThreadPoolExecutor to manage the threads. I am using a static singleton instance of a class, TP, that wraps around ThreadPoolExecutor (which is also static) because system A cannot create new objects but it can make calls to static objects.
Here is where I am stuck. I am doing some very basic testing of the setup before I go all out. I created two classes for testing, T1 & T2. Each of these classes imports the class TP (where the static singleton is created). T1 adds some objects to the TP queue and then T2 adds some more.
Even though the TP object is declared as static, it looks like there are two versions running in parallell. The objects submitted to the queue by T2 are being executed before the object submitted by T1 have all been executed. Also, since neither T1 or T2 calls shutdown() on the ThreadPoolExector, they both hang and never terminate.
How can I create a daemon static instance of a tread that basically wakes up whenever I send something to be processed, even from different Java executables?