Code example for SynchronousQueue

0
final class GeckoBackgroundThread extends Thread {
    private static final String LOOPER_NAME = "GeckoBackgroundThread";
 
    // Guarded by 'this'. 
    private static Handler sHandler = null;
    private SynchronousQueue<Handler> mHandlerQueue = new SynchronousQueue<Handler>();
 
    // Singleton, so private constructor. 
    private GeckoBackgroundThread() { 
        super(); 
    } 
 
    @Override 
    public void run() { 
        setName(LOOPER_NAME);
        Looper.prepare();
        try { 
            mHandlerQueue.put(new Handler());
        } catch (InterruptedException ie) {}
 
        Looper.loop();