Code example for BlockingQueue

Methods: clear, offer, poll, size

0
    private synchronized void StopThreadSendGpsData() { 
        if (m_threadSendGpsData != null && m_threadSendGpsData.isAlive()) {
            m_threadSendGpsData.interrupt();
        } 
        m_threadSendGpsData = null;
        m_sendLocations.clear();
    } 
 
    private BlockingQueue<String> m_sendLocations = new ArrayBlockingQueue<String>(m_queueCnt, true);
 
    public void SendTrackPointData(Location location) {
        if (!m_config.getIsUseWebService())
            return; 
 
        StartThreadSendGpsData(); 
        String gpsData = LocationToString(location);
 
        m_gpsDataAll++;
 
         if (m_sendLocations.size() >= m_queueCnt) {
            m_sendLocations.poll();
            m_gpsDataDrop++;
        } 
 
        m_sendLocations.offer(gpsData);
 
        //Log.d(TAG, "MyWeb:gpsData Queue count is " + Integer.toString(cnt)); 
    } 
 
    private void SendGpsData(String gpsData) {