Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Parallel processing

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

thanks
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A word of caution: Getting a task to execute reliably every second will be hard. Garbage collection could easily interfere with that.
 
Justin Russo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so it means we cannot do every sec?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic