Two Laptop Bag*
The moose likes Threads and Synchronization and the fly likes Parallel processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Parallel processing" Watch "Parallel processing" New topic

Parallel processing

Justin Russo
Ranch Hand

Joined: Oct 21, 2007
Posts: 77
Hello Friends,

I need some help. I am working on a project where there is a requirement to perform tasks periodically every 1 sec. I gave a lot thought and read thru lots of articles on the net. I came to one conclusion to use the java.util.concurrent api to solve my problem..

Steps are::
1. Create the tasks
2. Create Worker threads to execute tasks
3. Threads will send process the tasks and publish it to queue.

I need some advise for the third step. should i separate this tasks of publishing to separate thread.

Any good advise will be appreciated.


You Want it.. Get it.......the Right Way...<br /> <br />SCJP 5.0 SCWCD 5.0
Adam Michalik
Ranch Hand

Joined: Feb 18, 2008
Posts: 128
I'd imagine that the Executors Framework can be very helpful. All the worker threads share the same executor (which internally has a queue of tasks). Each worker thread submits the task to the executor. The queue, task, and executor are parts of the Executors Framework, so no effort on your side needed
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41180
A word of caution: Getting a task to execute reliably every second will be hard. Garbage collection could easily interfere with that.

Ping & DNS - my free Android networking tools app
Justin Russo
Ranch Hand

Joined: Oct 21, 2007
Posts: 77
so it means we cannot do every sec?
It is sorta covered in the JavaRanch Style Guide.
subject: Parallel processing
Similar Threads
ThreadPoolExecutor restart
Access webservices in Thread
Executing an EJB on a separate thread
When to use multithreading in business applications
No idea what is happening...