List of usage examples for android.os Process setThreadPriority
public static final native void setThreadPriority(int priority) throws IllegalArgumentException, SecurityException;
From source file:com.realtek.simpleconfig.SCTest.java
/** */ @SuppressWarnings("deprecation") public void DiscoverDevPopUp(final int milliSeconds) { discovDialog.setTitle("Wi-Fi: " + SCLib.getConnectedWifiSSID()); discovDialog.setMessage(" ?......"); discovDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); discovDialog.setCancelable(false);/*from ww w. jav a 2s .c o m*/ discovDialog.setButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DiscovEnable = false; dialog.cancel(); } }); discovDialog.show(); new Thread(new Runnable() { public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); byte[] DiscovCmdBuf = SCCtlOps.rtk_sc_gen_discover_packet(SCLib.rtk_sc_get_default_pin()); long startTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis(); while (DiscovEnable && (endTime - startTime) < milliSeconds) { SCLib.rtk_sc_send_discover_packet(DiscovCmdBuf, "255.255.255.255"); endTime = System.currentTimeMillis(); } Log.i(TAG, "Discover Time Elapsed: " + (endTime - startTime) + "ms"); // Update Status Message msg = Message.obtain(); msg.obj = null; msg.what = ~SCCtlOps.Flag.DiscoverACK; //timeout SCLib.TreadMsgHandler.sendMessage(msg); } }).start(); }
From source file:com.realtek.simpleconfig.SCTest.java
/** ?? */ public void SendCtlDevPacket(final int flag, final String pin, final String ip, final String new_name) { // Log.d(TAG, "ip: " + ip); // Log.d(TAG, "pin: " + pin); // Log.d(TAG, "name: " + new_name); new Thread(new Runnable() { int count = 0; public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); byte[] buf = SCCtlOps.rtk_sc_gen_control_packet(flag, SCLib.rtk_sc_get_default_pin(), pin, new_name); while (count < 15) { SCLib.rtk_sc_send_control_packet(buf, ip); count++;/* w w w . j av a 2 s . co m*/ } } }).start(); }
From source file:mobisocial.musubi.service.AddressBookUpdateHandler.java
public static AddressBookUpdateHandler newInstance(Context context, SQLiteOpenHelper dbh, ContentResolver resolver) {//from w ww .ja v a 2 s . c o m HandlerThread thread = new HandlerThread("AddressBookUpdateThread"); Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); thread.start(); AddressBookUpdateHandler abuh = new AddressBookUpdateHandler(context, dbh, thread, resolver); return abuh; }
From source file:com.grazerss.EntryManager.java
public void doUnsubscribeFeed(String feedAtomId) { try {//from w w w . j a va2 s. co m Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); synchronized (this) { if (isModelCurrentlyUpdated()) { return; } lockModel("EM.requestUnsubscribeFeed"); } if (canFeedBeUnsubscribed(feedAtomId)) { databaseHelper.addFeed2Unsubscribe(feedAtomId); DBQuery dbq = prepareMarkFeedReadQuery(feedAtomId); if (dbq != null) { doMarkAllRead(dbq); } } } finally { synchronized (this) { unlockModel("EM.requestUnsubscribeFeed"); } } }
From source file:com.newsrob.EntryManager.java
public void requestClearCacheAndSync() { try {//from w ww .j a v a 2 s .c o m runJob(new Job("Clearing Cache", EntryManager.this) { @Override public void run() throws Exception { try { Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); synchronized (this) { if (isModelCurrentlyUpdated()) return; lockModel("EM.requestClearCacheAndSync"); } doClearCache(); } finally { synchronized (this) { unlockModel("EM.requestClearCacheAndSync"); } } fireModelUpdated(); requestSynchronization(false); } }); } catch (final Throwable e) { showExceptionToast("Clear Cache And Sync", e); } }
From source file:com.facebook.react.ReactInstanceManager.java
@ThreadConfined(UI) private void runCreateReactContextOnNewThread(final ReactContextInitParams initParams) { Log.d(ReactConstants.TAG, "ReactInstanceManager.runCreateReactContextOnNewThread()"); UiThreadUtil.assertOnUiThread();/* w w w .j a v a 2s . c o m*/ synchronized (mReactContextLock) { if (mCurrentReactContext != null) { tearDownReactContext(mCurrentReactContext); mCurrentReactContext = null; } } mCreateReactContextThread = new Thread(null, new Runnable() { @Override public void run() { ReactMarker.logMarker(REACT_CONTEXT_THREAD_END); synchronized (ReactInstanceManager.this.mHasStartedDestroying) { while (ReactInstanceManager.this.mHasStartedDestroying) { try { ReactInstanceManager.this.mHasStartedDestroying.wait(); } catch (InterruptedException e) { continue; } } } // As destroy() may have run and set this to false, ensure that it is true before we create mHasStartedCreatingInitialContext = true; try { Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY); ReactMarker.logMarker(VM_INIT); final ReactApplicationContext reactApplicationContext = createReactContext( initParams.getJsExecutorFactory().create(), initParams.getJsBundleLoader()); mCreateReactContextThread = null; ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START); final Runnable maybeRecreateReactContextRunnable = new Runnable() { @Override public void run() { if (mPendingReactContextInitParams != null) { runCreateReactContextOnNewThread(mPendingReactContextInitParams); mPendingReactContextInitParams = null; } } }; Runnable setupReactContextRunnable = new Runnable() { @Override public void run() { try { setupReactContext(reactApplicationContext); } catch (Exception e) { mDevSupportManager.handleException(e); } } }; reactApplicationContext.runOnNativeModulesQueueThread(setupReactContextRunnable); UiThreadUtil.runOnUiThread(maybeRecreateReactContextRunnable); } catch (Exception e) { mDevSupportManager.handleException(e); } } }, "create_react_context"); ReactMarker.logMarker(REACT_CONTEXT_THREAD_START); mCreateReactContextThread.start(); }
From source file:com.newsrob.EntryManager.java
private void runSimpleJob(final String name, final Runnable runnable, final Handler handler) { new Thread(new Runnable() { public void run() { try { runJob(new Job(name, EntryManager.this) { @Override/*from w w w. ja v a 2s.c o m*/ public void run() throws Exception { try { Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); synchronized (this) { if (isModelCurrentlyUpdated()) return; lockModel(name); } runnable.run(); } finally { synchronized (this) { unlockModel(name); } } } }); } catch (final Throwable e) { if (handler != null) { handler.post(new Runnable() { public void run() { showExceptionToast(name, e); } }); } } } }).start(); }
From source file:com.facebook.react.ReactInstanceManager.java
private void setupReactContext(final ReactApplicationContext reactContext) { Log.d(ReactConstants.TAG, "ReactInstanceManager.setupReactContext()"); ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END); ReactMarker.logMarker(SETUP_REACT_CONTEXT_START); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext"); synchronized (mReactContextLock) { mCurrentReactContext = Assertions.assertNotNull(reactContext); }/*from www.j a va 2s .c om*/ CatalystInstance catalystInstance = Assertions.assertNotNull(reactContext.getCatalystInstance()); catalystInstance.initialize(); mDevSupportManager.onNewReactContextCreated(reactContext); mMemoryPressureRouter.addMemoryPressureListener(catalystInstance); moveReactContextToCurrentLifecycleState(); ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_START); synchronized (mAttachedRootViews) { for (ReactRootView rootView : mAttachedRootViews) { attachRootViewToInstance(rootView); } } ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_END); ReactInstanceEventListener[] listeners = new ReactInstanceEventListener[mReactInstanceEventListeners .size()]; final ReactInstanceEventListener[] finalListeners = mReactInstanceEventListeners.toArray(listeners); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { for (ReactInstanceEventListener listener : finalListeners) { listener.onReactContextInitialized(reactContext); } } }); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(SETUP_REACT_CONTEXT_END); reactContext.runOnJSQueueThread(new Runnable() { @Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); } }); reactContext.runOnNativeModulesQueueThread(new Runnable() { @Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); } }); }
From source file:com.realtek.simpleconfig.SCTest.java
private void rtk_sc_send_confirm_packet(final int flag) { new Thread(new Runnable() { String pin;//from ww w .j a v a2s . co m int count = 0; public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); if (CurrentView == 0) { // pin = PINSet; pin = (PINSet != null && PINSet.length() > 0) ? PINSet : "none"; } else { if (pinArrayList.size() > 0) { pin = pinArrayList.get(CurrentItem).toString(); } else { // Log.e(TAG, "pinArrayList is null"); return; } } // Log.d(TAG, "Comfirm PIN: " + pin); // Log.d(TAG, "Comfirm IP: " + CurrentControlIP); byte[] buf = SCCtlOps.rtk_sc_gen_control_confirm_packet(flag, SCLib.rtk_sc_get_default_pin(), pin); while (count < 5) { SCLib.rtk_sc_send_control_packet(buf, CurrentControlIP); count++; } } }).start(); }
From source file:com.grazerss.EntryManager.java
public void requestClearCacheAndSync() { try {//from w w w.j a v a2 s . co m runJob(new Job("Clearing Cache", EntryManager.this) { @Override public void run() throws Exception { try { Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); synchronized (this) { if (isModelCurrentlyUpdated()) { return; } lockModel("EM.requestClearCacheAndSync"); } doClearCache(); } finally { synchronized (this) { unlockModel("EM.requestClearCacheAndSync"); } } fireModelUpdated(); requestSynchronization(false); } }); } catch (final Throwable e) { showExceptionToast("Clear Cache And Sync", e); } }