/** * Stops the background thread and its {@link Handler}. */ private void stopBackgroundThread() { mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { e.printStackTrace(); } }
private synchronized void stopDraw() { if (handler != null) { handler.quit(); handler = null; } HandlerThread handlerThread = this.mHandlerThread; mHandlerThread = null; if (handlerThread != null) { try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private synchronized void stopDraw() { if (handler != null) { handler.quit(); handler = null; } HandlerThread handlerThread = this.mHandlerThread; mHandlerThread = null; if (handlerThread != null) { try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private void stopBackgroundThread() { if (Build.VERSION.SDK_INT > 17) { backgroundThread.quitSafely(); } else backgroundThread.quit(); try { backgroundThread.join(); } catch (InterruptedException e) { Log.e(TAG, "stopBackgroundThread: ", e); } finally { backgroundThread = null; backgroundHandler = null; } }
public void end() { mEndFlag = true; synchronized (mDrawingNotify) { mDrawingNotify.notifyAll(); } if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); mHandler.pause(); mHandler = null; } if (mThread != null) { try { mThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } mThread.quit(); mThread = null; } }
private synchronized void stopDraw() { if (this.handler == null) { return; } DrawHandler handler = this.handler; this.handler = null; unlockCanvasAndPost(); if (handler != null) { handler.quit(); } HandlerThread handlerThread = this.mHandlerThread; mHandlerThread = null; if (handlerThread != null) { try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private void release() throws InterruptedException { handler.post( () -> { try { if (player != null) { player.release(); } } catch (Exception e) { handleException(e); } finally { playerThread.quit(); } }); playerThread.join(); }
@After public void tearDown() throws Exception { // Try to ensure we've exited the thread at the end of each test if ( handlerThread != null ) { handlerThread.quit(); handlerThread.join(); } }
@Test public void shouldStopThreadIfLooperIsQuit() throws Exception { handlerThread = new HandlerThread("test1"); handlerThread.start(); Looper looper = handlerThread.getLooper(); assertFalse(shadowOf(looper).quit); looper.quit(); handlerThread.join(); assertFalse(handlerThread.isAlive()); assertTrue(shadowOf(looper).quit); handlerThread = null; }
private void release() throws InterruptedException { handler.post( () -> { try { if (player != null) { player.release(); } } catch (Exception e) { handleException(e); } finally { playerThread.quit(); } }); playerThread.join(); }
@Test public void shouldQuitLooperAndThread() throws Exception { handlerThread = new HandlerThread("test"); Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); handlerThread.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); handlerThread.start(); assertTrue(handlerThread.isAlive()); assertTrue(handlerThread.quit()); handlerThread.join(); assertFalse(handlerThread.isAlive()); handlerThread = null; }
/** * Stops the background thread and its {@link Handler}. */ private void stopBackgroundThread() { mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { e.printStackTrace(); } }
private void stopBackgroundThread() { if (Build.VERSION.SDK_INT > 17) { mBackgroundThread.quitSafely(); } else mBackgroundThread.quit(); try { mBackgroundThread.join(); } catch (InterruptedException e) { Log.e(TAG, "stopBackgroundThread: ", e); } finally { mBackgroundThread = null; mBackgroundHandler = null; } }
private void stopBackgroundThread() { Log.i(LOGTAG, "stopBackgroundThread"); if(mBackgroundThread == null) return; mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { Log.e(LOGTAG, "stopBackgroundThread"); } }
private void stopBackgroundThread() { Log.i(LOGTAG, "stopBackgroundThread"); if(mBackgroundThread == null) return; mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { Log.e(LOGTAG, "stopBackgroundThread"); } }
/** * Stops the background thread and its {@link Handler}. */ private void stopBackgroundThread() { mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { e.printStackTrace(); } }
/** * Stops the background thread and its {@link Handler}. */ private void stopBackgroundThread() { mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { e.printStackTrace(); } }
private void stopBackgroundThread() { Log.i(LOGTAG, "stopBackgroundThread"); if(mBackgroundThread == null) return; mBackgroundThread.quitSafely(); try { mBackgroundThread.join(); mBackgroundThread = null; mBackgroundHandler = null; } catch (InterruptedException e) { Log.e(LOGTAG, "stopBackgroundThread"); } }
/** * Stops the background thread and its {@link Handler}. */ private void stopBackgroundThread() { backgroundThread.quitSafely(); try { backgroundThread.join(); backgroundThread = null; } catch (final InterruptedException e) { LOGGER.e(e, "Exception!"); } }
private void stopBackgroundThread() { backgroundThread.quitSafely(); try { backgroundThread.join(); backgroundThread = null; backgroundHandler = null; } catch (InterruptedException e) { callbackHandler.onError(new Error(Error.ERROR_DEFAULT_CODE, e)); } }