James Clarke wrote:Doesn't answer the question. And your example is different.
Doesn't even bother to tell us which post it's in response to. And your original question was poorly defined, anyway.
James Clarke wrote:Does an instance of Dispatcher get created
You haven't shown enough code for anyone to determine that, really.
How (if at all) do you expect the code in your Dispatcher object to be run? It doesn't happen by magic, after all. It will only happen if you
do something to start a new thread. And the answer to your question depends on
what you do to start that thread. If you explicitly create a new Dispatcher instance, then yes, an instance of Dispatcher will be created. If you don't, it won't. It surely won't happen if you just
desire for some thread to execute your new run() method. There are several ways to cause a Runnable to execute. You have to pick one, and do it.
Even if you manage to instantiate a Dispatcher object and call its start() method (thereby creating a new Thread for which Thread.currentThread() would yield a Dispatcher instance) - we have no information about how this Listener class works. If something happens in the Dispatcher thread and the Listener is notified, is the Listener in the same thread as the Dispatcher? Maybe, maybe not. There are several common mechanisms for this, and they each yield different results. So there's no way to answer your question, really. It's far too soft on details to result in useful answers.
If you want to make your question more specific, consider: do you know how to start a new thread? At all? Can you write specific code to do so? And if you know more than one way, can you pick one, and tell us what it is? Similarly: can you write a mechanism for notifying a listener? And can you show us the code? If not (for any of these questions), perhaps it might be more useful if you focused on more fundamental questions. E.g. instead of "how does X (which I haven't really defined) affect Y?", try "how can I accomplish X?". And once you have some code for X, run it, and see what happens. Then you can replace "how does X affect Y?" with something much more specific, like "how come when I implemented X like this [show code], I got this result? [show result].
Basically, show more details of what you're wondering about, and we may well be able to help. Until then, probably not.