I have a separate thread, which is a loop thread that the handler declares, as shown below:
class LooperThread extends Thread{ Handler h = null; @Override public void run(){ Looper.prepare(); h = new MyHandler(); Looper.loop(); } }
And I also have a separate thread that sleeps. The code for myHandler synchronizes with the same lock as my other thread, and then calls Notify after doing some work. However, the original thread waits and the message that is sent from a separate service to the handler is not reached by the handler. I am sure the message is being sent from the service. I understand that Handler creates a message queue for the thread on which it was built, however, if the handler is built on a separate thread in the loop, will this thread not sleep if the original thread? I tried handlerThread and several other alternatives, but to no avail. Any help would be greatly appreciated. Thanks.
source share