Limited Number of threads.

i have created a loop which is running from 1 - 10000.

i that loop i am creating new thread and starting it. i don't what my program to run thousands of thread at a time . i want only 10 threads to run at a time, and new threads should be created only when one of the 10 thread completes.

Please tell me how to achieve this.

[351 byte] By [has_star] at [2007-9-30 6:22:18]
# 1
Sounds like you want to do some sort of thread pooling: http://www.google.com/search?q=java%2C+thread+pool&btnG=Search&hl=en&lr=&ie=UTF-8&oe=UTF-8
hungyee98 at 2007-7-1 20:41:49 > top of Java-index,Administration Tools,Sun Connection...