Thursday, September 29, 2011

WebLogic WorkManager for Multi-threading

WebLogic's WorkManager provides a self-tuned ThreadPool to enable Multi-Threading.

Define a WorkManager either in WLS console or in web.xml as below.


In weblogic-application.xml, you can configure the ThreadPool Size


Java Code

        try {
InitialContext ic = new InitialContext();
WorkManager workManager = (WorkManager)ic.lookup("java:comp/env/wm/MyWorkManager");
List workItemList=new ArrayList();

for(int i=0;i<10;i++){
WorkItem workItem1 = startWorkItem(my,i,"OSMM");

//run the work items in parallel; don't wait
//workManager.waitForAll(workItemList, WorkManager.IMMEDIATE);

    public WorkItem startWorkItem(WorkManager workManager, final int count, final String wmName) throws Exception{
WorkItem workItem10 = workManager.schedule(new Work() {
public void run() {
try {
System.out.println("Current Count ["+count+"] : wmName ["+wmName+"]ThreadName Is: "+Thread.currentThread().getName()+"##Priroty="+Thread.currentThread().getPriority());
} catch (Exception e) {

public void release() {

public boolean isDaemon() {
return false;
}); //End of Schedule
return workItem10;



Anonymous said...

is it possible to assign a workmanager to a pojo or any other service layer class ?
mine is web application and its mvc
so single servlet entry, how could i assign a work manager to models or pojos that do some business logic but i do not want that all threads gets blocked to a specific model at run time.

king pong siu said...

I m wondering if after waitForAll (with a timeout value), for those computation not completed..we could stop the computation and release immediately the related thread.

Alwin Co Daan said...

Very much useful article. Kindly keep blogging

Java Training in Chennai

Java Online Training India