當前位置: 首頁>>代碼示例>>Java>>正文


Java Process.setThreadPriority方法代碼示例

本文整理匯總了Java中android.os.Process.setThreadPriority方法的典型用法代碼示例。如果您正苦於以下問題:Java Process.setThreadPriority方法的具體用法?Java Process.setThreadPriority怎麽用?Java Process.setThreadPriority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Process的用法示例。


在下文中一共展示了Process.setThreadPriority方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.os.Process; //導入方法依賴的package包/類
@Override
public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    while (true) {
        try {
            ImageRequest request = mQueue.take();
            if (request.checkTaskNotActual()) {
                continue;
            }
            dealRequest(request);

        } catch (InterruptedException e) {
            // 如果要求退出則退出,否則遇到異常繼續
            if (mQuit) {
                return;
            } else {
                continue;
            }
        }
    }
}
 
開發者ID:shenhuanet,項目名稱:Sendroid,代碼行數:22,代碼來源:Dispatcher.java

示例2: doInBackground

import android.os.Process; //導入方法依賴的package包/類
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  // TODO(t11687218): Look over all threading
  // Default priority is Process.THREAD_PRIORITY_BACKGROUND which means we'll be put in a cgroup
  // that only has access to a small fraction of CPU time. The priority will be reset after
  // this task finishes: https://android.googlesource.com/platform/frameworks/base/+/d630f105e8bc0021541aacb4dc6498a49048ecea/core/java/android/os/AsyncTask.java#256
  Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);

  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor = params[0].getJsExecutorFactory().create();
    ReactApplicationContext reactApplicationContext =
      createReactContext(jsExecutor, params[0].getJsBundleLoader());
    ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
    return Result.of(reactApplicationContext);
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:21,代碼來源:ReactInstanceManager.java

示例3: newThread

import android.os.Process; //導入方法依賴的package包/類
@Override
public Thread newThread(final Runnable r) {
    Runnable wrapper = new Runnable() {
        @Override
        public void run() {
            try {
                //compression of the thread priority is 0.
                Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
            } catch (Throwable t) {
                t.printStackTrace();
            }
            r.run();
        }
    };

    String workThreadName = COMPRESS_THREAD_PREFIX_NAME + "-" + mThreadNumber.getAndIncrement();

    Thread thread = new Thread(wrapper, workThreadName);
    if (thread.isDaemon())
        thread.setDaemon(false);

    return thread;
}
 
開發者ID:tangqipeng,項目名稱:tiny,代碼行數:24,代碼來源:CompressThreadFactory.java

示例4: AndroidAsyncTask

import android.os.Process; //導入方法依賴的package包/類
/**
 * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
 */
public AndroidAsyncTask() {
    mWorker = new WorkerRunnable<Params, Result>() {
        public Result call() throws Exception {
            mTaskInvoked.set(true);

            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            //noinspection unchecked
            return postResult(doInBackground(mParams));
        }
    };

    mFuture = new FutureTask<Result>(mWorker) {
        @Override
        protected void done() {
            try {
                postResultIfNotInvoked(get());
            } catch (InterruptedException e) {
                android.util.Log.w(LOG_TAG, e);
            } catch (ExecutionException e) {
                throw new RuntimeException("An error occured while executing doInBackground()",
                        e.getCause());
            } catch (CancellationException e) {
                postResultIfNotInvoked(null);
            }
        }
    };
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:31,代碼來源:AndroidAsyncTask.java

示例5: AsyncTask

import android.os.Process; //導入方法依賴的package包/類
/**
 * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
 */
public AsyncTask() {
    mWorker = new WorkerRunnable<Params, Result>() {
        public Result call() throws Exception {
            mTaskInvoked.set(true);

            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            //noinspection unchecked
            return postResult(doInBackground(mParams));
        }
    };

    mFuture = new FutureTask<Result>(mWorker) {
        @Override
        protected void done() {
            try {
                postResultIfNotInvoked(get());
            } catch (InterruptedException e) {
                LogUtils.error(LOG_TAG, e.toString());
            } catch (ExecutionException e) {
                throw new RuntimeException("An error occured while executing doInBackground()",
                        e.getCause());
            } catch (CancellationException e) {
                postResultIfNotInvoked(null);
            }
        }
    };
}
 
開發者ID:PlutoArchitecture,項目名稱:Pluto-Android,代碼行數:31,代碼來源:AsyncTask.java

示例6: run

import android.os.Process; //導入方法依賴的package包/類
@Override
public void run() {
    mTid = Process.myTid();
    Looper.prepare();
    synchronized (this) {
        mLooper = Looper.myLooper();
        notifyAll();
    }
    Process.setThreadPriority(mPriority);
    onLooperPrepared();
    Looper.loop();
    mTid = -1;
}
 
開發者ID:m2049r,項目名稱:xmrwallet,代碼行數:14,代碼來源:MoneroHandlerThread.java

示例7: run

import android.os.Process; //導入方法依賴的package包/類
@Override
        public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            Display display = windowManager.getDefaultDisplay();

            int imageViewHeight;
            int imageViewWidth;

            if (Build.VERSION.SDK_INT < 13) {
                imageViewHeight = display.getHeight();
                imageViewWidth = display.getWidth();
            } else {
                Point size = new Point();
                display.getSize(size);
                imageViewHeight = size.y;
                imageViewWidth = size.x;
            }

//            int imageViewHeight = target.getMeasuredHeight();
//            int imageViewWidth = target.getMeasuredWidth();

            Bitmap decodedBitmap = decodeSampledBitmapFromResource(url, imageViewWidth, imageViewHeight);
            final Bitmap resultBitmap = rotateBitmap(decodedBitmap, getExifOrientation());

            mainHandler.post(new Runnable() {
                @Override
                public void run() {
                    target.setImageBitmap(resultBitmap);
                }
            });
        }
 
開發者ID:florent37,項目名稱:CameraFragment,代碼行數:34,代碼來源:ImageLoader.java

示例8: newThread

import android.os.Process; //導入方法依賴的package包/類
@Override
public Thread newThread(@NonNull Runnable runnable) {
    int threadNum = 0;
    return new Thread(runnable, threadName + threadNum++) {
        @Override
        public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            super.run();
        }
    };
}
 
開發者ID:shenhuanet,項目名稱:ZhidaoDaily-android,代碼行數:12,代碼來源:ThreadFactoryBuilder.java

示例9: onHandleIntent

import android.os.Process; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null) {
        return;
    }
    Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
    deleteExpiredApksFromCache();
    deleteStrayIndexFiles();
    deleteOldInstallerFiles();
    deleteOldIcons();
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:12,代碼來源:CleanCacheService.java

示例10: initNetworkThread

import android.os.Process; //導入方法依賴的package包/類
@SuppressWarnings("unused")
@CalledByNative
private void initNetworkThread() {
    synchronized (mLock) {
        mNetworkThread = Thread.currentThread();
        mInitCompleted.open();
    }
    Thread.currentThread().setName("ChromiumNet");
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:11,代碼來源:CronetUrlRequestContext.java

示例11: run

import android.os.Process; //導入方法依賴的package包/類
@Override
public void run() {
    try {
        Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
        GnLocale locale = new GnLocale(group,language,region,descriptor,gnUser);
        locale.setGroupDefault();
    } catch (GnException e) {
        Log.e(TAG, e.errorCode() + ", " + e.errorDescription() + ", " + e.errorModule(), e);
    }
}
 
開發者ID:aschober,項目名稱:vinyl-cast,代碼行數:11,代碼來源:MusicRecognizer.java

示例12: AsyncTask

import android.os.Process; //導入方法依賴的package包/類
/**
 * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
 */
public AsyncTask() {
    mWorker = new WorkerRunnable<Params, Result>() {
        public Result call() throws Exception {
            mTaskInvoked.set(true);

            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            //noinspection unchecked
            return postResult(doInBackground(mParams));
        }
    };

    mFuture = new FutureTask<Result>(mWorker) {
        @Override
        protected void done() {
            try {
                postResultIfNotInvoked(get());
            } catch (InterruptedException e) {
                android.util.Log.w(LOG_TAG, e);
            } catch (ExecutionException e) {
                throw new RuntimeException("An error occured while executing doInBackground()",
                        e.getCause());
            } catch (CancellationException e) {
                postResultIfNotInvoked(null);
            }
        }
    };
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:31,代碼來源:AsyncTask.java

示例13: run

import android.os.Process; //導入方法依賴的package包/類
public void run() {
    Process.setThreadPriority(10);
    insertIntoDB(this.mThreadInfo);
    try {
        this.mStatus = 104;
        executeDownload();
        synchronized (this.mOnDownloadListener) {
            this.mStatus = 105;
            this.mOnDownloadListener.onDownloadCompleted();
        }
    } catch (DownloadException e) {
        handleDownloadException(e);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:15,代碼來源:DownloadTaskImpl.java

示例14: newThread

import android.os.Process; //導入方法依賴的package包/類
@Override
public Thread newThread(@NonNull final Runnable r) {
    Runnable wrapper = new Runnable() {
        @Override
        public void run() {
            try {
                Process.setThreadPriority(mThreadPriority);
            } catch (Throwable t) {
                Log.e(TAG, "run: ", t);
            }
            r.run();
        }
    };
    return new Thread(wrapper);
}
 
開發者ID:amitkma,項目名稱:Stitch,代碼行數:16,代碼來源:PriorityThreadFactory.java

示例15: initNetworkThread

import android.os.Process; //導入方法依賴的package包/類
@CalledByNative
private void initNetworkThread() {
    Thread.currentThread().setName("ChromiumNet");
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:6,代碼來源:ChromiumUrlRequestContext.java


注:本文中的android.os.Process.setThreadPriority方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。