calling a client on a specific thread
I'm porting a .NET project to java and I’m looking for the best way to notify clients of an event on a thread that they specify.
In .NET my event notification class has a set_SynchronizingObject method that takes as a parameter the .NET ISynchronizeInvoke interface, which has the InvokeRequired and Invoke methods, among others, to achieve this. The client initializes my event notification class with a reference to a listener and an instance of the ISynchronizeInvoke interface. To notify the client of an event, the event notification class does something like this:
Event notification class
if (clientImplementationOfISynchronizeInvoke.InvokeRe quired)
create an object that represents MyMethod
The client’s implementation of ISynchronizeInvoke::Invoke is responsible for calling MyMethod on the appropriate thread.
My questions are:
1) Is there something similar to ISynchronizeInvoke in java?
2) If not, is there a “best practices” way to implement this functionality?
3) A more general question -- how do I invoke a method on a specific thread?
Thanks in advance for your thoughts.