Untitled

 avatar
unknown
plain_text
a year ago
595 B
14
Indexable
    public static class HighPriorityThreadFactory implements ThreadFactory {
        @Override
        public Thread newThread(Runnable r) {
            Thread thread = new Thread(r);
            thread.setPriority(Thread.MAX_PRIORITY);
            return thread;
        }
    }

    public static final Executor HIGH_PRIORITY_EXECUTOR = new ThreadPoolExecutor(
            5, 128, 1, TimeUnit.SECONDS, null, new HighPriorityThreadFactory());

    // Execute AsyncTask using high priority executor
    public void executeHighPriority() {
        executeOnExecutor(HIGH_PRIORITY_EXECUTOR);
    }
Editor is loading...
Leave a Comment