Code example for ArrayBlockingQueue

0
 
            BlockingQueue<String> mMessageQueue;
            private int QUEUE_CAPACITY = 10;
 
            public SendingThread() { 
                mMessageQueue = new ArrayBlockingQueue<String>(QUEUE_CAPACITY);
            } 
 
            @Override 
            public void run() { 
                try { 
                    if (getSocket() == null) { 
                        setSocket(new Socket(mAddress, PORT));
                        Log.d(CLIENT_TAG, "Client-side socket initialized.");
 
                    } else { 
                        Log.d(CLIENT_TAG, "Socket already initialized. skipping!");
                    } 
 
                    mRecThread = new Thread(new ReceivingThread());
                    mRecThread.start();