本文整理汇总了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;
}
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
};
}
示例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);
}
}
};
}
示例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;
}
示例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);
}
});
}
示例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();
}
};
}
示例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();
}
示例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);
}
示例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);
}
}
示例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);
}
}
};
}
示例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);
}
}
示例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);
}
示例15: initNetworkThread
import android.os.Process; //导入方法依赖的package包/类
@CalledByNative
private void initNetworkThread() {
Thread.currentThread().setName("ChromiumNet");
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}