Created
July 10, 2016 16:37
-
-
Save amitshekhariitbhu/9bc3f1e384b6a437051708d8e12e214e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PriorityThreadFactory implements ThreadFactory { | |
private final int mThreadPriority; | |
public PriorityThreadFactory(int threadPriority) { | |
mThreadPriority = threadPriority; | |
} | |
@Override | |
public Thread newThread(final Runnable runnable) { | |
Runnable wrapperRunnable = new Runnable() { | |
@Override | |
public void run() { | |
try { | |
Process.setThreadPriority(mThreadPriority); | |
} catch (Throwable t) { | |
} | |
runnable.run(); | |
} | |
}; | |
return new Thread(wrapperRunnable); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment