This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Pooling using jdk 1.5

 
Achalveer Singh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
please tell me how i should implement thread pooling using jdk1.5 .
by using java.util.concurrent.* package.
what i have to do.

i have to make a class and i have to put for loop that send continuously message . thread pool of size 100 threads. when more then 100 message are coming then there should be queue for message.

please give me code if anyone has for this application.
 
Henry Wong
author
Marshal
Pie
Posts: 21506
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Achalveer Singh:
hi all,
please tell me how i should implement thread pooling using jdk1.5 .
by using java.util.concurrent.* package.
what i have to do.

i have to make a class and i have to put for loop that send continuously message . thread pool of size 100 threads. when more then 100 message are coming then there should be queue for message.

please give me code if anyone has for this application.


Threadpool support is built into Java 5 -- no need to implement it.

Take a look at the java.util.concurrent.Executors class. This is a convenience factory for the creation of the most common configurations of threadpools.

Henry
 
Achalveer Singh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i know java 1.5 provides thread pool.
but i want to know how to use it according to my question.
please read question first before answering.
 
Hung Tang
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

please give me code if anyone has for this application.

Achalveer, here's a tip: no one is going to do your homework for you.

please read question first before answering.

<sarcasm>This will surely get you some help.</sarcasm>

Why don't you go do some research on your own and come back with some real results before mouthing off in the forums.
 
Achalveer Singh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think forum is for discussing the problem . please discuss the problem it will be better.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try the Javadoc linked above? The Executor interface page might also be a good starting point. There are code samples and more.

In short, you call Executors to get a concrete Executor implementation. Then you give the Executor a bunch of tasks to run. That's about it. What specific questions does that raise for you?
[ April 05, 2007: Message edited by: Stan James ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic