org.apache.tomcat.util.threads.ThreadPoolExecutor.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中org.apache.tomcat.util.threads.ThreadPoolExecutor.<init>()方法的一些代码示例,展示了ThreadPoolExecutor.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.<init>()方法的具体详情如下:
包路径:org.apache.tomcat.util.threads.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:<init>

ThreadPoolExecutor.<init>介绍

暂无

代码示例

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

private static AsynchronousChannelGroup createAsynchronousChannelGroup() {
  // Need to do this with the right thread context class loader else the
  // first web app to call this will trigger a leak
  ClassLoader original = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(
        AsyncIOThreadFactory.class.getClassLoader());
    // These are the same settings as the default
    // AsynchronousChannelGroup
    int initialSize = Runtime.getRuntime().availableProcessors();
    ExecutorService executorService = new ThreadPoolExecutor(
        0,
        Integer.MAX_VALUE,
        Long.MAX_VALUE, TimeUnit.MILLISECONDS,
        new SynchronousQueue<Runnable>(),
        new AsyncIOThreadFactory());
    try {
      return AsynchronousChannelGroup.withCachedThreadPool(
          executorService, initialSize);
    } catch (IOException e) {
      // No good reason for this to happen.
      throw new IllegalStateException(sm.getString("asyncChannelGroup.createFail"));
    }
  } finally {
    Thread.currentThread().setContextClassLoader(original);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

private static AsynchronousChannelGroup createAsynchronousChannelGroup() {
  // Need to do this with the right thread context class loader else the
  // first web app to call this will trigger a leak
  ClassLoader original = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(
        AsyncIOThreadFactory.class.getClassLoader());
    // These are the same settings as the default
    // AsynchronousChannelGroup
    int initialSize = Runtime.getRuntime().availableProcessors();
    ExecutorService executorService = new ThreadPoolExecutor(
        0,
        Integer.MAX_VALUE,
        Long.MAX_VALUE, TimeUnit.MILLISECONDS,
        new SynchronousQueue<Runnable>(),
        new AsyncIOThreadFactory());
    try {
      return AsynchronousChannelGroup.withCachedThreadPool(
          executorService, initialSize);
    } catch (IOException e) {
      // No good reason for this to happen.
      throw new IllegalStateException(sm.getString("asyncChannelGroup.createFail"));
    }
  } finally {
    Thread.currentThread().setContextClassLoader(original);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

private static AsynchronousChannelGroup createAsynchronousChannelGroup() {
  // Need to do this with the right thread context class loader else the
  // first web app to call this will trigger a leak
  ClassLoader original = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(
        AsyncIOThreadFactory.class.getClassLoader());
    // These are the same settings as the default
    // AsynchronousChannelGroup
    int initialSize = Runtime.getRuntime().availableProcessors();
    ExecutorService executorService = new ThreadPoolExecutor(
        0,
        Integer.MAX_VALUE,
        Long.MAX_VALUE, TimeUnit.MILLISECONDS,
        new SynchronousQueue<Runnable>(),
        new AsyncIOThreadFactory());
    try {
      return AsynchronousChannelGroup.withCachedThreadPool(
          executorService, initialSize);
    } catch (IOException e) {
      // No good reason for this to happen.
      throw new IllegalStateException(sm.getString("asyncChannelGroup.createFail"));
    }
  } finally {
    Thread.currentThread().setContextClassLoader(original);
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

private static AsynchronousChannelGroup createAsynchronousChannelGroup() {
  // Need to do this with the right thread context class loader else the
  // first web app to call this will trigger a leak
  ClassLoader original = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(
        AsyncIOThreadFactory.class.getClassLoader());
    // These are the same settings as the default
    // AsynchronousChannelGroup
    int initialSize = Runtime.getRuntime().availableProcessors();
    ExecutorService executorService = new ThreadPoolExecutor(
        0,
        Integer.MAX_VALUE,
        Long.MAX_VALUE, TimeUnit.MILLISECONDS,
        new SynchronousQueue<Runnable>(),
        new AsyncIOThreadFactory());
    try {
      return AsynchronousChannelGroup.withCachedThreadPool(
          executorService, initialSize);
    } catch (IOException e) {
      // No good reason for this to happen.
      throw MESSAGES.asyncGroupFail();
    }
  } finally {
    Thread.currentThread().setContextClassLoader(original);
  }
}

代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote

public void createExecutor() {
  internalExecutor = true;
  TaskQueue taskqueue = new TaskQueue();
  TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
  taskqueue.setParent( (ThreadPoolExecutor) executor);
}

代码示例来源:origin: codefollower/Tomcat-Research

public void createExecutor() {
  internalExecutor = true;
  TaskQueue taskqueue = new TaskQueue();
  TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
  taskqueue.setParent( (ThreadPoolExecutor) executor);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

public void createExecutor() {
  internalExecutor = true;
  TaskQueue taskqueue = new TaskQueue();
  TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
  taskqueue.setParent( (ThreadPoolExecutor) executor);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

public void createExecutor() {
  internalExecutor = true;
  TaskQueue taskqueue = new TaskQueue();
  TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
  taskqueue.setParent( (ThreadPoolExecutor) executor);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public void createExecutor() {
  internalExecutor = true;
  TaskQueue taskqueue = new TaskQueue();
  TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
  taskqueue.setParent( (ThreadPoolExecutor) executor);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  executor.setThreadRenewalDelay(threadRenewalDelay);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Start the component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {
  taskqueue = new TaskQueue(maxQueueSize);
  TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
  executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
  executor.setThreadRenewalDelay(threadRenewalDelay);
  if (prestartminSpareThreads) {
    executor.prestartAllCoreThreads();
  }
  taskqueue.setParent(executor);
  setState(LifecycleState.STARTING);
}

相关文章