I am writing a TCP server class that I want to be standalone. That is, applications using this class do not have to worry about internal workflows. The TCP server class has a start () method, and I want to be able to call listener methods on the same thread called start () (in normal use, the main thread). This is probably better explained by the code:
public class ProblemExample { private Listener mListener; public ProblemExample() { mListener = new Listener() { @Override public void fireListener() { System.out.println(Thread.currentThread().getName()); } }; } public void start() { mListener.fireListener();
I tried looking for this, but I'm not sure what to look for. The best I have found is SwingWorker , it seems like this, but I canβt find out how to do it.
Can anyone shed some light?
source share