Code example for Semaphore

0
 
	// cache 
	private final HashMap<String, CacheItem> cacheStorage = new HashMap<String, CacheItem>();
 
	// work queue for background thread 
	private final Semaphore queryQueueLock = new Semaphore(1, true);
	private final LinkedList<QueueJob> queryQueue = new LinkedList<QueueJob>();
	 
	// DPI 
	public static final int DENSITY_LOW = 120;
	public static final int DENSITY_MEDIUM = 160;
	public static final int DENSITY_HIGH = 240;
	public static final int DENSITY_XHIGH = 320;
	public static final int DENSITY_XXHIGH = 480;
 
	public static ProcessUtil getInstance(Context context, boolean detail) {
 
		if (singletone == null) {
			singletone = new ProcessUtil();
 
			singletone.packageMgr = context.getPackageManager();