HandlerThread bgThread = new HandlerThread("handler name"); Process.setThreadPriority(bgThread.getThreadId(), Process.THREAD_PRIORITY_BACKGROUND); bgThread.start(); mBgHandler = new Handler(bgThread.getLooper());
@Override public void run() { LOGGER.debug("TID: " + ht.getThreadId() + " trying to reconnect to session"); if (mqttClient != null && !mqttClient.isConnected()) { reconnectToSession(); } ht.quit(); } }, MILLIS_IN_ONE_SECOND * currentReconnectRetryTime);
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is * posted on the worker thread handler. */ private static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is * posted on the worker thread handler. */ private static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is * posted on the worker thread handler. */ private static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }
@Override public void run() { Log.i(TAG, "createHandler(id : %d)", handlerThread.getThreadId()); } });
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is * posted on the worker thread handler. */ private static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }
public static void assertWorkerThread() { if (LauncherAppState.isDogfoodBuild() && (LauncherModel.sWorkerThread.getThreadId() != Process.myTid())) { throw new IllegalStateException(); } }
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is * posted on the worker thread handler. */ @Thunk static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }
/** Runs the specified runnable immediately if called from the main thread, otherwise it is * posted on the main thread handler. */ private void runOnMainThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { // If we are on the worker thread, post onto the main handler mHandler.post(r); } else { r.run(); } }
private void runOnMainThread(Runnable r, int type) { if (sWorkerThread.getThreadId() == Process.myTid()) { // If we are on the worker thread, post onto the main handler mHandler.post(r); } else { r.run(); } }
/** Runs the specified runnable immediately if called from the main thread, otherwise it is * posted on the main thread handler. */ private void runOnMainThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { // If we are on the worker thread, post onto the main handler mHandler.post(r); } else { r.run(); } }
/** Runs the specified runnable immediately if called from the main thread, otherwise it is * posted on the main thread handler. */ private void runOnMainThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { // If we are on the worker thread, post onto the main handler mHandler.post(r); } else { r.run(); } }
/** Runs the specified runnable immediately if called from the main thread, otherwise it is * posted on the main thread handler. */ @Thunk void runOnMainThread(Runnable r) { if (sWorkerThread.getThreadId() == Process.myTid()) { // If we are on the worker thread, post onto the main handler mHandler.post(r); } else { r.run(); } }
private void unbindItemInfosAndClearQueuedBindRunnables() { if (sWorkerThread.getThreadId() == Process.myTid()) { throw new RuntimeException("Expected unbindLauncherItemInfos() to be called from the " + "main thread"); } // Clear any deferred bind runnables synchronized (mDeferredBindRunnables) { mDeferredBindRunnables.clear(); } // Remove any queued UI runnables mHandler.cancelAll(); // Unbind all the workspace items unbindWorkspaceItemsOnMainThread(); }
public void unbindItemInfosAndClearQueuedBindRunnables() { if (sWorkerThread.getThreadId() == Process.myTid()) { throw new RuntimeException("Expected unbindLauncherItemInfos() to be called from the " + "main thread"); } // Clear any deferred bind runnables synchronized (mDeferredBindRunnables) { mDeferredBindRunnables.clear(); } // Remove any queued bind runnables mHandler.cancelAllRunnablesOfType(MAIN_THREAD_BINDING_RUNNABLE); // Unbind all the workspace items unbindWorkspaceItemsOnMainThread(); }
boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid()); if (isRunningOnMainThread) { r.run();
boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid()); if (isRunningOnMainThread) { r.run();
boolean found = false; synchronized (app) { if (sWorkerThread.getThreadId() != Process.myTid()) {
@Override public void run() { LOGGER.debug("TID: " + ht.getThreadId() + " trying to reconnect to session"); if (mqttClient != null && !mqttClient.isConnected()) { reconnectToSession(); } ht.quit(); } }, MILLIS_IN_ONE_SECOND * currentReconnectRetryTime);