• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A couple of init() questions...

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

In my init() method, I want a loop that loops forever ( while(true){... ). Can I do this in the init() method? Do I just do it in a new thread?

Also, what is the purpose of the super.init(config) line? What happens if I leave it in? What happens if I leave it out?

Thanks,
James
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like that should be in another thread. Kicked off in a context listener. You should also make sure you have a solid way of killing this thread from the contextDestroyed method of your listener or make sure you are using daemon threads. Otherwise, you may have trouble reloading your app and/or stopping and restarting you server.

I generally advise against starting your own threads in a webapp unless, you really know what you're doing and can't find any alternative.

Mind sharing what you are using the loop for?

-Ben
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hiya Ben,

Thanks for the reply.

It's to constantly re-read a dynamic web page, from which the servlet is taking the required bits to create a new web page.

Cheers,
James
reply
    Bookmark Topic Watch Topic
  • New Topic