当前位置: 首页>>代码示例>>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;未经允许,请勿转载。