Threads in application server

Discussions

General J2EE: Threads in application server

  1. Threads in application server (3 messages)

    We are developing an web application on orion server. What I want is to have a thread running all the time checking my db for an entry. Im starting this thread from a servlet but It seems that the the thread dies with the servlet.

    How do you get it to run longer than that? Should this be the time to introduce EJBs to our project?

    I appreciate all the help I can get.

    /H
  2. Run something that's part of the startup class essentially. If you use something like a singleton like pattern you can then also make sure it doesn't get GCed.
  3. You can implement runable inteface to the servlet and run this thread in init() method of servlet this method is called by the containter on server start in deploy time. See servlet specification.
  4. Threads in application server[ Go to top ]

    Hi,

    Although I do not know the Orion Server creating threads in an application server is frowned upon.

    I would recommend writing a separate stand alone Java program the runs a thread that checks the db at the required interval.

    You could of course write a db trigger that fires when data is added to your table. I beleive Oracle triggers allow the calling of Java code now.

    David