summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/async/AndroidPriorityThread.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/async/AndroidPriorityThread.java')
-rw-r--r--src/com/android/camera/async/AndroidPriorityThread.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/camera/async/AndroidPriorityThread.java b/src/com/android/camera/async/AndroidPriorityThread.java
new file mode 100644
index 000000000..f12bcb210
--- /dev/null
+++ b/src/com/android/camera/async/AndroidPriorityThread.java
@@ -0,0 +1,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();
+ }
+}