Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!