Code example for Semaphore

Methods: drainPermits

0
    			NetworkInfo netInfo = cm.getActiveNetworkInfo(); 
    			if (netInfo != null) 
    				if (netInfo.isConnected() == true) 
    					connectivity_semaphore.release();			// release semaphore 
    				else 
    					connectivity_semaphore.drainPermits();		// drain semaphore 
 
				return; 
            } 
        } 
	}; 
	 
    private class LocationReceiver implements LocationListener 
    { 
        public void	 onLocationChanged(Location location)        
        { 
        	if (location != null)
        	{				 
				Longitude 	= location.getLongitude();
				Latitude 	= location.getLatitude();