Forums Register Login

Polling/Triggering thread

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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)
+Pie Number of slices to send: Send
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!
Always look on the bright side of life. At least this ad is really tiny:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1172 times.
Similar Threads
Process, Runtime, Thread
long running service call and tracking completion
Please Wait Window
Showing the status of an operation
Implementing multi-threading in a Standalone client-server environment
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:20:04.