summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/async/AndroidPriorityThread.java
blob: f12bcb210dce22a76fad42755cab29de2fd6076f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

package com.android.camera.async;

/**
 * A thread that runs at the given Android thread priority.
 */
public class AndroidPriorityThread extends Thread {
    private final int mAndroidThreadPriority;

    /**
     * Constructs the new thread.
     *
     * @param androidThreadPriority the android priority the thread should run
     *            at. This has to be one of the
     *            android.os.Process.THREAD_PRIORITY_* values.
     * @param runnable the runnable to run at this thread priority.
     */
    public AndroidPriorityThread(int androidThreadPriority, Runnable runnable) {
        super(runnable);
        mAndroidThreadPriority = androidThreadPriority;
    }

    @Override
    public void run() {
        android.os.Process.setThreadPriority(mAndroidThreadPriority);
        super.run();
    }
}