Search in sources :

Example 1 with BasicThreadFactory

use of org.apache.commons.lang3.concurrent.BasicThreadFactory in project Activiti by Activiti.

the class DefaultAsyncJobExecutor method initAsyncJobExecutionThreadPool.

protected void initAsyncJobExecutionThreadPool() {
    if (threadPoolQueue == null) {
        log.info("Creating thread pool queue of size {}", queueSize);
        threadPoolQueue = new ArrayBlockingQueue<Runnable>(queueSize);
    }
    if (executorService == null) {
        log.info("Creating executor service with corePoolSize {}, maxPoolSize {} and keepAliveTime {}", corePoolSize, maxPoolSize, keepAliveTime);
        BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("activiti-async-job-executor-thread-%d").build();
        executorService = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, threadPoolQueue, threadFactory);
    }
}
Also used : BasicThreadFactory(org.apache.commons.lang3.concurrent.BasicThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 2 with BasicThreadFactory

use of org.apache.commons.lang3.concurrent.BasicThreadFactory in project xwiki-platform by xwiki.

the class DefaultWikiProvisioningJobExecutor method initialize.

@Override
public void initialize() throws InitializationException {
    this.jobs = new HashMap<List<String>, WikiProvisioningJob>();
    // Setup jobs thread
    BasicThreadFactory factory = new BasicThreadFactory.Builder().namingPattern("XWiki provisioning thread").daemon(true).priority(Thread.MIN_PRIORITY).build();
    this.jobExecutor = Executors.newCachedThreadPool(factory);
}
Also used : BasicThreadFactory(org.apache.commons.lang3.concurrent.BasicThreadFactory) ArrayList(java.util.ArrayList) List(java.util.List) WikiProvisioningJob(org.xwiki.wiki.provisioning.WikiProvisioningJob)

Example 3 with BasicThreadFactory

use of org.apache.commons.lang3.concurrent.BasicThreadFactory in project tutorials by eugenp.

the class Lang3UtilsTest method testBuildDefaults.

@Test
public void testBuildDefaults() {
    BasicThreadFactory.Builder builder = new BasicThreadFactory.Builder();
    BasicThreadFactory factory = builder.build();
    assertNull("No naming pattern set Yet", factory.getNamingPattern());
    BasicThreadFactory factory2 = builder.namingPattern("sampleNamingPattern").daemon(true).priority(Thread.MIN_PRIORITY).build();
    assertNotNull("Got a naming pattern", factory2.getNamingPattern());
    assertEquals("sampleNamingPattern", factory2.getNamingPattern());
}
Also used : BasicThreadFactory(org.apache.commons.lang3.concurrent.BasicThreadFactory) Test(org.junit.Test)

Aggregations

BasicThreadFactory (org.apache.commons.lang3.concurrent.BasicThreadFactory)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Test (org.junit.Test)1 WikiProvisioningJob (org.xwiki.wiki.provisioning.WikiProvisioningJob)1