Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Polling/Triggering thread  RSS feed

 
Torsten Schindler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi *,

My status: Thread newbie.

My goal:
A servlet which can be queried by an task_id for the current status of tasks
(running/stopped/failed/succeed), which polls different SOAP webservices
by an id until the webservice job finished.

My questions:
1) Can anyone give me some working example code for
a AbstractTask + ConcreteTask + TaskController/TaskMonitor + WorkerThread +
PollingWorker class (mentioned in Doug Lea's, Concurrent Programming
in Java, Second Edition, page 302)?
2) What is the best way to monitor (from a servlet) the status of a task running in an separate thread.

Best,

Torsten
 
Magnus Palm�r
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Have you checked out Doug Lea's util.concurrent package?
(His package is now moved/migrated/refactored into java.util.concurrent in 1.5).

I think that the Fork/Join Tasks section might be something of interest for you.
Overview of package util.concurrent Release 1.3.4.

(I use the PooledExecuter with a BoundedLinkedQueue alot myself)
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd look for a way for each worker thread to post its current task status now & then to a shared resource, maybe a static map keyed by task name. Then a servlet running on its own thread could dig through the map and find the status of any interesting tasks.

How the threads post would be interesting. They could have direct access to the shared resource, go through some kind of pub-sub or listener interface, use queues, whatever fits the situation.

"Shared resource" raises a red flag for synchronizing access, of course.

Let us know what you wind up with!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!