Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Waking dynamic threads

 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applcication that needs to write into 36 different files. I will get to know the size of the data to be written only during run time. So based on the file sizes i need to wake dynamic threads. I have decided that there will be 3-5 threads, but I done know how!!! please help me in doing things.

Naresh
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into the thread pooling in Java 5. Some number of threads sit and wait for work to appear in a queue. When a Runnable object appears, one of the threads pulls it off the queue and runs it. Start with the JavaDoc for Executors and Google for examples.

In your case it sounds like the Runnable would process a file in its run() method, and you'd put a Runnable in queue any time you spot a new file.
[ February 20, 2006: Message edited by: Stan James ]
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!