org.jboss.threads.JBossExecutors.directExecutor()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(124)

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

JBossExecutors.directExecutor介绍

[英]Get the direct executor. This executor will immediately run any task it is given, and propagate back any run-time exceptions thrown.
[中]找直接执行人。此执行器将立即运行它指定的任何任务,并传播回抛出的任何运行时异常。

代码示例

代码示例来源:origin: wildfly/wildfly

/**
 * Create a new instance.
 *
 * @param coreThreads the number of threads to create before enqueueing tasks
 * @param maxThreads the maximum number of threads to create
 * @param keepAliveTime the amount of time that an idle thread should remain active
 * @param keepAliveTimeUnit the unit of time for {@code keepAliveTime}
 * @param queue the queue to use for tasks
 * @param threadFactory the thread factory to use for new threads
 * @param blocking {@code true} if the executor should block when the queue is full and no threads are available, {@code false} to use the handoff executor
 * @param handoffExecutor the executor which is called when blocking is disabled and a task cannot be accepted, or {@code null} to reject the task
 */
public QueueExecutor(final int coreThreads, final int maxThreads, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
  this(coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, queue, threadFactory, blocking, handoffExecutor, JBossExecutors.directExecutor());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an executor that executes each task in a new thread.
 *
 * @param factory the thread factory to use
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory) {
  return new ThreadFactoryExecutor(factory, Integer.MAX_VALUE, false, directExecutor());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Defer interrupts for the duration of some task.  Once the task is complete, any deferred interrupt will be
 * delivered to the thread, thus the thread interrupt status should be checked upon return.  If the current thread
 * is not a {@code JBossThread}, the task is simply run as-is.
 *
 * @param task the task to run
 */
public static void executeWithInterruptDeferred(final Runnable task) {
  executeWithInterruptDeferred(JBossExecutors.directExecutor(), task);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Run a task, invoking the given notifier with the given attachment.
 *
 * @param task the task
 * @param notifier the notifier
 * @param attachment the attachment
 * @param <R> the task type
 * @param <A> the attachment type
 */
public static <R extends Runnable, A> void run(R task, TaskNotifier<? super R, ? super A> notifier, A attachment) {
  run(task, directExecutor(), notifier, attachment);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an executor that executes each task in a new thread.  By default up to the given number of threads may run
 * concurrently, after which new tasks will be rejected.
 *
 * @param factory the thread factory to use
 * @param maxThreads the maximum number of allowed threads
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory, final int maxThreads) {
  return new ThreadFactoryExecutor(factory, maxThreads, false, directExecutor());
}

代码示例来源:origin: wildfly/wildfly

public static ExecutorService directExecutorService() {
  return new DelegatingExecutorService(JBossExecutors.directExecutor());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create an executor that executes each task in a new thread.  By default up to the given number of threads may run
 * concurrently, after which the caller will block or new tasks will be rejected, according to the setting of the
 * {@code blocking} parameter.
 *
 * @param factory the thread factory to use
 * @param maxThreads the maximum number of allowed threads
 * @param blocking {@code true} if the submitter should block when the maximum number of threads has been reached
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory, final int maxThreads, final boolean blocking) {
  return new ThreadFactoryExecutor(factory, maxThreads, blocking, directExecutor());
}

代码示例来源:origin: wildfly/wildfly

public static ExecutorService directExecutorService() {
  return new DelegatingExecutorService(JBossExecutors.directExecutor());
}

代码示例来源:origin: wildfly/wildfly

/**
 * Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
 * You must have the {@link RuntimePermission}{@code ("modifyThread")} permission to use this method.
 *
 * @param delegate the delegate thread factory
 * @return the resetting thread factory
 * @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
 * permission
 */
public static ThreadFactory resettingThreadFactory(final ThreadFactory delegate) throws SecurityException {
  return wrappingThreadFactory(resettingExecutor(directExecutor()), delegate);
}

代码示例来源:origin: org.wildfly.core/wildfly-server

public FutureServiceContainer() {
  super(JBossExecutors.directExecutor());
}

代码示例来源:origin: org.jboss.threads/jboss-threads

/**
 * Run a task, invoking the given notifier with the given attachment.
 *
 * @param task the task
 * @param notifier the notifier
 * @param attachment the attachment
 * @param <R> the task type
 * @param <A> the attachment type
 */
public static <R extends Runnable, A> void run(R task, TaskNotifier<? super R, ? super A> notifier, A attachment) {
  run(task, directExecutor(), notifier, attachment);
}

代码示例来源:origin: org.jboss.threads/jboss-threads

/**
 * Defer interrupts for the duration of some task.  Once the task is complete, any deferred interrupt will be
 * delivered to the thread, thus the thread interrupt status should be checked upon return.  If the current thread
 * is not a {@code JBossThread}, the task is simply run as-is.
 *
 * @param task the task to run
 */
public static void executeWithInterruptDeferred(final Runnable task) {
  executeWithInterruptDeferred(JBossExecutors.directExecutor(), task);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Defer interrupts for the duration of some task.  Once the task is complete, any deferred interrupt will be
 * delivered to the thread, thus the thread interrupt status should be checked upon return.  If the current thread
 * is not a {@code JBossThread}, the task is simply run as-is.
 *
 * @param task the task to run
 */
public static void executeWithInterruptDeferred(final Runnable task) {
  executeWithInterruptDeferred(JBossExecutors.directExecutor(), task);
}

代码示例来源:origin: org.jboss.threads/jboss-threads

/**
 * Create an executor that executes each task in a new thread.
 *
 * @param factory the thread factory to use
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory) {
  return new ThreadFactoryExecutor(factory, Integer.MAX_VALUE, false, directExecutor());
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Create an executor that executes each task in a new thread.
 *
 * @param factory the thread factory to use
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory) {
  return new ThreadFactoryExecutor(factory, Integer.MAX_VALUE, false, directExecutor());
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Run a task, invoking the given notifier with the given attachment.
 *
 * @param task the task
 * @param notifier the notifier
 * @param attachment the attachment
 * @param <R> the task type
 * @param <A> the attachment type
 */
public static <R extends Runnable, A> void run(R task, TaskNotifier<? super R, ? super A> notifier, A attachment) {
  run(task, directExecutor(), notifier, attachment);
}

代码示例来源:origin: org.jboss.threads/jboss-threads

/**
 * Create an executor that executes each task in a new thread.  By default up to the given number of threads may run
 * concurrently, after which new tasks will be rejected.
 *
 * @param factory the thread factory to use
 * @param maxThreads the maximum number of allowed threads
 * @return the executor
 * @deprecated Use {@link EnhancedQueueExecutor} instead.
 */
@Deprecated
public static BlockingExecutor threadFactoryExecutor(final ThreadFactory factory, final int maxThreads) {
  return new ThreadFactoryExecutor(factory, maxThreads, false, directExecutor());
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
 * You must have the {@link RuntimePermission}{@code ("modifyThread")} permission to use this method.
 *
 * @param delegate the delegate thread factory
 * @return the resetting thread factory
 * @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
 * permission
 */
public static ThreadFactory resettingThreadFactory(final ThreadFactory delegate) throws SecurityException {
  return wrappingThreadFactory(resettingExecutor(directExecutor()), delegate);
}

代码示例来源:origin: org.jboss.threads/jboss-threads

/**
 * Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
 * You must have the {@link RuntimePermission}{@code ("modifyThread")} permission to use this method.
 *
 * @param delegate the delegate thread factory
 * @return the resetting thread factory
 * @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
 * permission
 */
public static ThreadFactory resettingThreadFactory(final ThreadFactory delegate) throws SecurityException {
  return wrappingThreadFactory(resettingExecutor(directExecutor()), delegate);
}

代码示例来源:origin: wildfly/wildfly-core

public synchronized void start(final StartContext context) throws StartException {
  final TimeSpec keepAliveSpec = keepAlive;
  long keepAlive = keepAliveSpec == null ? Long.MAX_VALUE : keepAliveSpec.getUnit().toMillis(keepAliveSpec.getDuration());
  final QueuelessExecutor queuelessExecutor = new QueuelessExecutor(threadFactoryValue.getValue(), JBossExecutors.directExecutor(), handoffExecutorValue.getOptionalValue(), keepAlive);
  queuelessExecutor.setMaxThreads(maxThreads);
  queuelessExecutor.setBlocking(blocking);
  executor = new ManagedQueuelessExecutorService(queuelessExecutor);
}

相关文章

微信公众号

最新文章

更多