Java ThreadFactory createThreadFactory(final String threadName, final int stackSize)

Here you can find the source of createThreadFactory(final String threadName, final int stackSize)

Description

Returns a ThreadFactory that creates threads that run at minimum priority

License

Open Source License

Declaration

public static ThreadFactory createThreadFactory(final String threadName, final int stackSize) 

Method Source Code

//package com.java2s;
/**/*ww  w. j  av a  2 s  .c  om*/
 * Copyright (C) 2009  HungryHobo@mail.i2p
 * 
 * The GPG fingerprint for HungryHobo@mail.i2p is:
 * 6DD3 EAA2 9990 29BC 4AD2 7486 1E2C 7B61 76DC DC12
 * 
 * This file is part of I2P-Bote.
 * I2P-Bote is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * I2P-Bote is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with I2P-Bote.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.concurrent.ThreadFactory;

public class Main {
    /** Returns a <code>ThreadFactory</code> that creates threads that run at minimum priority */
    public static ThreadFactory createThreadFactory(final String threadName, final int stackSize) {
        return createThreadFactory(threadName, stackSize, Thread.MIN_PRIORITY);
    }

    public static ThreadFactory createThreadFactory(final String threadName, final int stackSize,
            final int priority) {
        return new ThreadFactory() {
            @Override
            public Thread newThread(Runnable runnable) {
                Thread newThread = new Thread(Thread.currentThread().getThreadGroup(), runnable, threadName,
                        stackSize);
                newThread.setPriority(priority);
                return newThread;
            }
        };
    }
}

Related

  1. createDaemonThreadFactory(final int threadPriority, final ThreadGroup group, final ClassLoader contextClassLoader)
  2. createFactory(final String threadName)
  3. createNamedThreadFactory(final String threadName)
  4. createSimpleThreadFactory(final String name)
  5. CreateThreadFactory(final ThreadGroup tg, final String threadName)
  6. createThreadFactory(String nameFormat, Thread.UncaughtExceptionHandler exceptionHandler)
  7. createThreadFactory(String namePrefix)
  8. createThreadFactoryBuilder(final String baseName, final String componentName)