[jboss-jira] [JBoss JIRA] (AS7-2034) Asynchronous EJB thread pool maximum size is set to "Runtime.getRuntime().availableProcessors()"
Stian Thorgersen (Updated) (JIRA)
jira-events at lists.jboss.org
Fri Oct 7 05:07:15 EDT 2011
[ https://issues.jboss.org/browse/AS7-2034?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stian Thorgersen updated AS7-2034:
----------------------------------
Steps to Reproduce: Deploy the attach JAR, or create one yourself from the attached source. When deployed the AsyncBean#execute method will be executed "2 x Runtime.getRuntime().availableProcessors()" times. Observe that the number of concurrent threads executing the method are never higher than "Runtime.getRuntime().availableProcessors()" (was: Deploy the following beans:
{code}
package com.example;
import java.util.concurrent.atomic.AtomicInteger;
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
@Stateless
public class AsyncBean
{
private static AtomicInteger threads = new AtomicInteger();
@Asynchronous
public void execute()
{
System.out.println("Starting " + Thread.currentThread().getName() + ", threads: " + threads.incrementAndGet());
try
{
Thread.sleep(10000);
}
catch (InterruptedException e)
{
}
System.out.println("Completed " + Thread.currentThread().getName() + ", threads: " + threads.decrementAndGet());
}
}
{code}
and
{code}
package com.example;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
@Singleton
@Startup
public class InvokerBean
{
@EJB
private AsyncBean async;
@PostConstruct
public void invoke()
{
System.out.println("Starting");
int n = Runtime.getRuntime().availableProcessors() * 2;
for (int i = 0; i < n; i++)
{
async.execute();
}
System.out.println("Completed " + n);
}
}
{code}
)
Forum Reference: http://community.jboss.org/message/630399 (was: http://community.jboss.org/message/630399)
> Asynchronous EJB thread pool maximum size is set to "Runtime.getRuntime().availableProcessors()"
> ------------------------------------------------------------------------------------------------
>
> Key: AS7-2034
> URL: https://issues.jboss.org/browse/AS7-2034
> Project: Application Server 7
> Issue Type: Bug
> Affects Versions: 7.0.2.Final
> Reporter: Stian Thorgersen
> Attachments: agility-async_test.jar, AsyncBean.java, InvokerBean.java
>
>
> The thread pool service used to execute @Asynchronous EJB methods have been set to "Runtime.getRuntime().availableProcessors()". This is clearly not a sensible default as on a single core CPU (or VM) only a single @Asynchronous method is executed concurrently. I would imagine a sensible default would be at least 10.
> It would also be very useful if it was possible set this value in the configuration files.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list