DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006

    Spawning multiple threads inside a Servlet

    Hi All,

    We have a situtation where we need to crawl various sites/databases for information to perform a search. The most efficient way is to multithread the application as we all know. Since J2EE discourages custom Multithreading, we had to search for alternatives to accomplish this task.

    We came across few interesting solutions using JMS/MDB. Other than using these is there a simpler way to accomplish this. Any help is appreciated...


  2. #2
    Join Date
    Oct 2004
    Searching this way possibly takes a long time (even when using multiple threads). I've had a similar application a while back where I had to custom build a j2me midlet when a user access the download page. I solved it by going through the following steps:
    1: user enteres what he wants in a webform.
    2: webform is submitted to the server, which stored it in the database.
    3: a second application which listenes on the database is automatically started and begins the process of compiling the midlet. While this compilation is in progress the webpage polls every 5 seconds to check if the midlet is completed.
    4: once the midlet is completed, the application sets a flag in the database to 1.
    5: the next poll from the client, the webserver sees the midlet is complete and starts streaming it to the client.

    Using this approach, I disconnected the time consuming action of compiling the application from the actual webserver process. This has the added benefit that you can run it on a seperate server if need be.
    You can port this to your situation by using the secondary application to perform the actual search and add the results of the search either to the database, or store in file on thefile system.
    During the polling of the client, you can show a nice moving gif of a running clock or somethings like that.


  3. #3
    Join Date
    Feb 2006
    Thanks Mark, Looks like a good idea...

    - Srini

Similar Threads

  1. SQL Help and Servlet help
    By trixma in forum Java
    Replies: 4
    Last Post: 09-09-2005, 08:12 AM
  2. Servlet Help
    By trixma in forum Java
    Replies: 4
    Last Post: 09-04-2005, 11:10 PM
  3. using threads in servlet
    By Loganathan in forum Java
    Replies: 0
    Last Post: 01-25-2001, 12:48 AM
  4. Replies: 1
    Last Post: 12-10-2000, 02:59 PM
  5. Replies: 0
    Last Post: 04-04-2000, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.