Fast way to pass a simple java object from one thread to another
- by Adal
I have a callback which receives an object. I make a copy of this object, and I must pass it on to another thread for further processing. It's very important for the callback to return as fast as possible. Ideally, the callback will write the copy to some sort of lock-free container.
I only have the callback called from a single thread and one processing thread.
I only need to pass a bunch of doubles to the other thread, and I know the maximum number of doubles (around 40).
Any ideas? I'm not very familiar with Java, so I don't know the usual ways to pass stuff between threads.