[Tom Henricksen:] What would be a better way to accomplishing this? I am open to any suggestions. I realize the fundamental misunderstanding here, and a lot of posters will argue effectively for some contemporary tools and design suites, but in order to have an object
do something you have to trap the thread in a do or while and if you do that, you get a virtual flock of ravin Ravens all over the place. Thread Pool management really belongs in jvm and implementation code, not in userland. Grudgingly, I agree with PC:
Or, even better, avoid ever dirtying your hands with actual Thread objects, by using concurrency utilities, thread pools etc., but that's if concurrency utilities are available in whatever implementation you are using.
Write your data object as you would normally write in java, put a run() method in it and have that run method do whatever work it is that you need to have done to get the object in a state that is useable. Keep a ref to it in ( possibly ) some sort of collection and iterate to get useable data.
Call run as described in Thread.java, not in any other way than that described in Thread.java -> otherwise use some fancy tool. EE has plenty of fancy tools and you would be able to find something there that works.
JavaTM 2 Platform Enterprise Edition, v 1.4 has ServletContextListener as being an interface, reading farther, it becomes apparent that the event comes in as a
ServletContextEvent, what that means is that you do not use Threads, as you are understanding them and trying, somewhat valliantly in the face of Crocodile Alley, to implement them. The Thread, as you are calling it, comes in as getServletContext(), which then proceeds ( after a few links ) to ServletResponse, which is described in Marty Hall's book rather effectively.
Java Server Pages, if you read Marty Hall's book, will do what you are trying to do without getting into messes like Peter Chase's citation of Edward Harned and ensuing discussions.
Don't try to implement run() methods, nor do as I say at the outset of this post, just write some
jsp, and let the jsp and server do the threading. There are init() methods in jsp that will allow you to do the setup and placing of data objects as you need them.
What, in general terms, do you need to access in the iterator ?
{ message edit: See
The Single threadModel Interface. in
servlets and Bill Brogden's
Java Servlet and JavaServer Pages Resources } [ November 25, 2007: Message edited by: Nicholas Jordan ]