Results 1 to 2 of 2
  1. #1
    crank6015 is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default need help with thread pool

    i have a program that download's a webpage to a string, and makes some process to it.
    now i need to make a thread pool with 4 threads, that take all the hyperlinks from the original page, and does the same process, with 4 threads only.
    i'm really new to java, so i would appreciate detailed explanation.

    i've read few tutorials about executor class, but i cant seem to understand where to begin from.
    do i make the class that does all the work on the string as runnable, or do i make a new executor class??

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Blog Entries
    Rep Power


    You can proceed like this:
    1. Write thread class, which does your processing.
    2. Use Executors' class different apis (whichever suits your requirement best)
    3. Call execute method of the ExecutorService (returned by Executor in step 2 above).

    Java Code:
    ExecutorService servicePool = Executors.newCachedThreadPool();
    servicePool.execute(new Thread());

Similar Threads

  1. Replies: 0
    Last Post: 02-11-2011, 03:21 PM
  2. How to correctly use a fixed size thread pool?
    By johann_p in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-19-2010, 02:04 AM
  3. using snaq.db for connection pool
    By Li Xiao in forum JDBC
    Replies: 1
    Last Post: 08-08-2010, 10:28 AM
  4. Thread Count Extends Beyond Pool
    By jvermast in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-01-2010, 07:47 AM
  5. connection pool for db2
    By paty in forum JDBC
    Replies: 1
    Last Post: 08-06-2007, 02:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts