Java Code Examples for android.os.Process#THREAD_PRIORITY_LOWEST
The following examples show how to use
android.os.Process#THREAD_PRIORITY_LOWEST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppsCustomizePagedView.java From TurboLauncher with Apache License 2.0 | 5 votes |
/** * Return the appropriate thread priority for loading for a given page (we give the current * page much higher priority) */ private int getThreadPriorityForPage(int page) { int pageDiff = getWidgetPageLoadPriority(page); if (pageDiff <= 0) { return Process.THREAD_PRIORITY_LESS_FAVORABLE; } else if (pageDiff <= 1) { return Process.THREAD_PRIORITY_LOWEST; } else { return Process.THREAD_PRIORITY_LOWEST; } }
Example 2
Source File: AppsCustomizePagedView.java From LB-Launcher with Apache License 2.0 | 5 votes |
/** * Return the appropriate thread priority for loading for a given page (we give the current * page much higher priority) */ private int getThreadPriorityForPage(int page) { // TODO-APPS_CUSTOMIZE: detect number of cores and set thread priorities accordingly below int pageDiff = getWidgetPageLoadPriority(page); if (pageDiff <= 0) { return Process.THREAD_PRIORITY_LESS_FAVORABLE; } else if (pageDiff <= 1) { return Process.THREAD_PRIORITY_LOWEST; } else { return Process.THREAD_PRIORITY_LOWEST; } }
Example 3
Source File: Priority.java From Rocket with Apache License 2.0 | 4 votes |
@IntRange(from = Process.THREAD_PRIORITY_FOREGROUND, to = Process.THREAD_PRIORITY_LOWEST) int priority();
Example 4
Source File: ThreadPoolExecutorWithExceptions.java From Android-Vault with Apache License 2.0 | 4 votes |
private void setDefaultOsPriority(int defaultOsPriority) { if (defaultOsPriority < Process.THREAD_PRIORITY_URGENT_AUDIO || defaultOsPriority > Process.THREAD_PRIORITY_LOWEST) { throw new IllegalArgumentException("Cannot set thread priority to " + defaultOsPriority); } mDefaultOsPriority = defaultOsPriority; }
Example 5
Source File: ImageLoaderManager.java From appcan-android with GNU Lesser General Public License v3.0 | 4 votes |
public void run() { /* 设置任务线程为后台线程,获得更少的执行机会,减少对UI渲染的影响 */ int threadPriority = Process.getThreadPriority(Process.myTid()); if (threadPriority != Process.THREAD_PRIORITY_LOWEST) { Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST); } final ImageLoadTask loadTask = seekReadyTask(); if (loadTask == null) { handler.sendEmptyMessage(ACTION_LOAD_FINISH); return; } try { // 从磁盘去取 Bitmap bitmap = DiskCache.readCache(loadTask.getKey()); if (bitmap == null) {// 尚未缓存,从源去取 bitmap = loadFromSource(loadTask); } if (bitmap != null) {// 取得图片成功 // 将bitmap放入LruCache缓存列表 memoryCache.put(loadTask.filePath, bitmap); } final Bitmap finalBitmap = bitmap; if (loadTask.getCallBack() != null) { handler.post(new Runnable() { @Override public void run() { loadTask.performCallback(finalBitmap); } }); } } catch (OutOfMemoryError e) { memoryCache.evictAll(); System.gc(); e.printStackTrace(); BDebug.e(TAG, "OutOfMemoryError!!!!!!!!!!!!!!!!!!!!:" + e.getMessage()); } finally { if (loadTask != null) { synchronized (taskList) { taskList.remove(loadTask); } } } }
Example 6
Source File: ReadaheadThread.java From prettygoodmusicplayer with GNU General Public License v3.0 | 4 votes |
public ReadaheadThread() { mScratch = new byte[BYTES_PER_READ]; HandlerThread handlerThread = new HandlerThread("ReadaheadThread", Process.THREAD_PRIORITY_LOWEST); handlerThread.start(); mHandler = new Handler(handlerThread.getLooper(), this); }
Example 7
Source File: ITask.java From android-performance with MIT License | 2 votes |
/** * 优先级的范围,可根据Task重要程度及工作量指定;之后根据实际情况决定是否有必要放更大 * * @return */ @IntRange(from = Process.THREAD_PRIORITY_FOREGROUND, to = Process.THREAD_PRIORITY_LOWEST) int priority();