Code example for SynchronousQueue

0
    private class JSInterface { 
        public SynchronousQueue<String> mMessageQueue;
 
        JSInterface() { 
            mMessageQueue = new SynchronousQueue<String>();
        } 
 
        public void pushMessage(String message) {
            Log.d("WebView", message);
            try { 
                mMessageQueue.put(message);
            } catch (java.lang.InterruptedException e) {
                Log.d("WebView", "Queueing error - " + e.getMessage());
            } 
        } 
    } 
 
    private JSInterface mJSInterface;   // JavaScript interface (message receiver)
    private WebView mWebView;           // WebView object
    private ProgressBar mProgress;      // Progress bar
    private int mLeftMargin;            // Margins around the WebView