Java Code Examples for android.os.Process#THREAD_PRIORITY_MORE_FAVORABLE
The following examples show how to use
android.os.Process#THREAD_PRIORITY_MORE_FAVORABLE .
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: TaskDelayChecker.java From Rocket with Apache License 2.0 | 6 votes |
/** * 延时确认任务是否已经完成 * * @param tasks * @param delayTimeMillis * @param iTimeoutHandler */ public static void delayCheckTaskAlive(final List<LaunchTask> tasks, long delayTimeMillis, final ITimeoutHandler iTimeoutHandler) { if (delayTimeMillis <= 0 || iTimeoutHandler == null) { return; } final HandlerThread handlerThread = new HandlerThread("rocket-task-timeout-checker", Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE); handlerThread.start(); new Handler(handlerThread.getLooper()).postDelayed(new Runnable() { @Override public void run() { List<LaunchTask> undoneTasks = new ArrayList<>(); //如果当前还有任务没有完成的话,输出异常 int size = tasks.size(); for (int i = 0; i < size; i++) { final LaunchTask task = tasks.get(i); if (!task.isDone()) { undoneTasks.add(task); } } if (!undoneTasks.isEmpty()) { iTimeoutHandler.onTimeout(undoneTasks); } handlerThread.quit(); } }, delayTimeMillis); }
Example 2
Source File: CameraStreamer.java From peepers with Apache License 2.0 | 6 votes |
void start() { synchronized (mLock) { if (mRunning) { throw new IllegalStateException("CameraStreamer is already running"); } // if mRunning = true; } // synchronized final HandlerThread worker = new HandlerThread(TAG, Process.THREAD_PRIORITY_MORE_FAVORABLE); worker.setDaemon(true); worker.start(); mLooper = worker.getLooper(); mWorkHandler = new WorkHandler(mLooper); mWorkHandler.obtainMessage(MESSAGE_TRY_START_STREAMING).sendToTarget(); }
Example 3
Source File: IMUManager.java From mobile-ar-sensor-logger with GNU General Public License v3.0 | 5 votes |
/** * This will register all IMU listeners * https://stackoverflow.com/questions/3286815/sensoreventlistener-in-separate-thread */ public void register() { mSensorThread = new HandlerThread("Sensor thread", Process.THREAD_PRIORITY_MORE_FAVORABLE); mSensorThread.start(); // Blocks until looper is prepared, which is fairly quick Handler sensorHandler = new Handler(mSensorThread.getLooper()); mSensorManager.registerListener( this, mAccel, mSensorRate, sensorHandler); mSensorManager.registerListener( this, mGyro, mSensorRate, sensorHandler); }
Example 4
Source File: LaunchTask.java From Rocket with Apache License 2.0 | 4 votes |
@Override public int priority() { return Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE; }
Example 5
Source File: TestTask2.java From Rocket with Apache License 2.0 | 4 votes |
@Override public int priority() { return super.priority() + Process.THREAD_PRIORITY_MORE_FAVORABLE; }
Example 6
Source File: TestTask1.java From Rocket with Apache License 2.0 | 4 votes |
@Override public int priority() { //线程优先级,默认Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE return super.priority() + Process.THREAD_PRIORITY_MORE_FAVORABLE; }
Example 7
Source File: MediaPlayer.java From droidel with Apache License 2.0 | 4 votes |
/** @hide */ public void addSubtitleSource(InputStream is, MediaFormat format) throws IllegalStateException { final InputStream fIs = is; final MediaFormat fFormat = format; // Ensure all input streams are closed. It is also a handy // way to implement timeouts in the future. synchronized(mOpenSubtitleSources) { mOpenSubtitleSources.add(is); } // process each subtitle in its own thread final HandlerThread thread = new HandlerThread("SubtitleReadThread", Process.THREAD_PRIORITY_BACKGROUND + Process.THREAD_PRIORITY_MORE_FAVORABLE); thread.start(); Handler handler = new Handler(thread.getLooper()); handler.post(new Runnable() { private int addTrack() { if (fIs == null || mSubtitleController == null) { return MEDIA_INFO_UNSUPPORTED_SUBTITLE; } SubtitleTrack track = mSubtitleController.addTrack(fFormat); if (track == null) { return MEDIA_INFO_UNSUPPORTED_SUBTITLE; } // TODO: do the conversion in the subtitle track Scanner scanner = new Scanner(fIs, "UTF-8"); String contents = scanner.useDelimiter("\\A").next(); synchronized(mOpenSubtitleSources) { mOpenSubtitleSources.remove(fIs); } scanner.close(); mOutOfBandSubtitleTracks.add(track); track.onData(contents, true /* eos */, ~0 /* runID: keep forever */); return MEDIA_INFO_EXTERNAL_METADATA_UPDATE; } public void run() { int res = addTrack(); if (mEventHandler != null) { Message m = mEventHandler.obtainMessage(MEDIA_INFO, res, 0, null); mEventHandler.sendMessage(m); } thread.getLooper().quitSafely(); } }); }