I have a problem with a specific java client library. Here is the situation:
I have made a program that uses the library. The program is a class named 'WorkerThread' that extends Thread. To start it I have made a Main class that only contains a main() function that starts the thread and nothing else. The worker uses the library to perform comm with a server and get results. The problem appears when I want to run 2 WorkerThreads simultaneously. What I first did was to do this in the Main class:
public class Main
{
public static void main(String args[])
{
new WorkerThread().start(); // 1st thread.
new WorkerThread().start(); // 2nd thread.
}
}
When I run this, both threads produce irrational results and what is more , some results that should be received by 1st thread are received by the 2nd instead.
If instead of the above, I just run 2 separate processes of one thread each, then everything works fine.
Also:
1.There is no static class or method used inside WorkerThread that could cause the problem. My application consists of only the worker thread class and contains no static fields or methods
2.The library is supposed to be usable in a multithreaded environment. In my thread I just create a new instance of a library's class and then call methods on it. Nothing more.
My question is this: Without knowing any details of my implementation, is the above situation and facts enough to prove that there is a bug in the library and not in my programm? Is it safe to assume that the library might for example use a static object or an object shared between library created threads that is indirectly shared by my 2 threads and this causes the problem? If no then in what hypothetical situation could the bug originate in the worker class code?
EDIT: I didnt say the library because i want to know if the facts above can produce an answer to my question independently of the library, but anyway the library is rabbit mq java client. Each thread creates 1 connection and 2 channels and uses one to publish data and one to receive results.
EDIT 2: New fact: Problem seems to depend on the rate at which I send stuff to the queues. Sending in slower rate lowers the amount of wrong results.