Code example for Semaphore

Methods: acquire

0
 * Window - Preferences - Java - Code Style - Code Templates 
 */ 
public class MediaWatcherHandler implements Handler 
{ 
	private boolean camera, music, pictures, videos;
	private Semaphore watcher_semaphore 	= new Semaphore(1);
	private boolean installed = false;
	private OwnObserver camera_observer = null, music_observer = null, pictures_observer = null, videos_observer = null;
	private String watched_file;
	private String watched_type;
	private boolean reading_sensor = false;
	private String camera_directory, music_directory, pictures_directory, videos_directory;
	 
	/** 
	 * Sleep function  
	 * @param millis 
	 */ 
	protected void sleep(long millis) 
	{ 
		Waker.sleep(millis);
	} 
	 
	private void wait(Semaphore sema)
	{ 
		try 
		{ 
			sema.acquire();
		} 
		catch(Exception e)
		{ 
		} 
	}