Code example for HandlerThread

Methods: getLooper, isAlive, start

0
	} 
 
	@Override 
	public void startWatching() { 
		mThreadName = FileWatcher.class.getSimpleName();
		if (mThread == null || !mThread.isAlive()) {
 
			FileLogger.printInfo("startFileWather new HandlerThread..."); 
			mThread = new HandlerThread(mThreadName,Process.THREAD_PRIORITY_BACKGROUND);
			mThread.start();
 
			mThreadHandler = new Handler(mThread.getLooper());
			mThreadHandler.post(new startRunnable());
		} 
	} 
	 
	@Override 
	public void stopWatching() { 
		if(null != mThreadHandler && null != mThread && mThread.isAlive()){
			mThreadHandler.post(new stopRunnable());
		}