@Override public void run() { mHandlerThread.interrupt(); mMainHandler.removeCallbacks(mBitmapFetchRunnable); mBackgroundHandler.removeCallbacks(mEventDispatchRunnable); mIsRunning = false; mHandlerThread = null; mBitmap = null; mCanvas = null; mStream = null; } }
/** * Attempts to stop the working task, halts the processing of waiting tasks, and returns a list * of the tasks that were awaiting execution. These tasks are drained (removed) from the task * queue upon return from this method. */ public List<BaseDownloadTask> shutdown() { synchronized (finishCallback) { if (workingTask != null) { pause(); } final List<BaseDownloadTask> unDealTaskList = new ArrayList<>(pausedList); pausedList.clear(); mHandler.removeMessages(WHAT_NEXT); mHandlerThread.interrupt(); mHandlerThread.quit(); return unDealTaskList; } }
public void close() { rfbQueueThread.interrupt(); handler.removeCallbacks(null); handler.getLooper().quit(); }
private void initialise() { if (libTorrentThread != null && torrentSession != null) { resumeSession(); } else { if ((initialising || initialised) && libTorrentThread != null) { libTorrentThread.interrupt(); } initialising = true; initialised = false; initialisingLatch = new CountDownLatch(1); libTorrentThread = new HandlerThread(LIBTORRENT_THREAD_NAME); libTorrentThread.start(); libTorrentHandler = new Handler(libTorrentThread.getLooper()); libTorrentHandler.post(new Runnable() { @Override public void run() { torrentSession = new SessionManager(); setOptions(torrentOptions); torrentSession.addListener(dhtStatsAlertListener); torrentSession.startDht(); initialising = false; initialised = true; initialisingLatch.countDown(); } }); } }
@Override public void stop() { mIsStarted = false; if (null != mCallbackHandler) { mCallbackHandler.removeCallbacksAndMessages(null); } mHandler.removeCallbacksAndMessages(null); HandlerThread handlerThread = mHandlerThread; mHandlerThread = null; handlerThread.quit(); try { handlerThread.join(10); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.interrupt(); }
/** * Closes all resources related to the shell. */ @Override public synchronized void close() { try { shell.close(); } catch (Exception ignored) { } synchronized (callbackThread) { callbackThread.notifyAll(); } callbackThread.interrupt(); callbackThread.quit(); closed = true; if (onCloseListener != null) { onCloseListener.onClosed(this); } }
public void onDestroy() { mBackgroundHandler.removeCallbacksAndMessages(null); mCameraRenderer.onDestroy(); CameraController.getInstance().release(); if (!mHandlerThread.isInterrupted()) { try { mHandlerThread.quit(); mHandlerThread.interrupt(); } catch (Exception e) { e.printStackTrace(); } } }
streamingThread.interrupt();