This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

WebSphere Asynch Beans

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've three threads. T1 is main thread and T2 is the child thread. I've to perform a task on Thread T2 in both Synchronous as well as Asynchronous manner by using an explicit call from Thread T1. For Async call, I'm using my code as below.

Context ctx = null;
ctx = new InitialContext();
WorkManager wm = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_JNDI_NAME);
WorkManager slaveWM = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_SLAVE_JNDI_NAME);
AValhallaAsyncMgr asyncMgr = new AsyncRatesBookingRequestHandler(slaveWM, req.getRequestContextBean());
wm.startWork(asyncMgr); //Async Validation

The above code snippet is working good. But for Synchronous call, I need to initiate the child thread T2 from main thread T1 and I should execute it asynchronusly without affecting T1 performance and join the response to parent thread T1. Currently I'm using the code snippet as like below.

Context ctx = null;
ctx = new InitialContext();
WorkManager wm = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_JNDI_NAME);
WorkManager slaveWM = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_SLAVE_JNDI_NAME);
AValhallaAsyncMgr asyncMgr = new AsyncRatesBookingRequestHandler(slaveWM, req.getRequestContextBean(),req,respBo,logOrFail,new RatesWorkStatusHandler());
wm.doWork(asyncMgr); //Sync Validation

The problem here is, when doWork() is being called, T1 is continuing with its execution, without being waited for T2 to finish of its execution. I can allow only 200ms for T2 to execute, means I can allow T1 to wait for only 200ms. If T2 exceeds this time, T1 is not getting the update from T2. How can I achieve this???

Thanks,
Gayathri
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic