From: Martin R. <ma...@vi...> - 2004-06-13 16:05:03
|
ofcourse another kind of "simpler" way would be that at the start of your servlet you'll get the system's currenttimemillis, mark it up, then in your time consuming tasks you check if the current time minus the marked up time is over your timeout and then decide over the result if you should continue the operation or not. this would be very easy to implement and also very efficient. ofcourse one-size-doesn't-fit-all applies here so you must be very certain that this can or will help you out. as for why-shouldn't-i-slay-my-threads-in-cold-blood: let's imagine you have a db transaction open and you abort the thread just like that ... a nice way would be rollback the stuff immidately but if you slay the thread there's none to rollback it. also the table would probably remain locked until the sql connection that triggered the transaction dies. martin Martin Roos wrote: > i'm affraid you have to start another thread by yourself and somehow > check if your thread should abort all actions is some breakpoints of your > code. if you are looking for performance take a look at some threadpool > which would allow you to pool the forking threads. in the forked thread > you just > wait for that either N seconds (the time limit) have passed or the servlet > has finished it's job. if it hasn't then alter some variable which the > servlet must > test in some points of your code and return immidately doing > must-be-done cleanups > on it's way out. if you are using an mvc style framework it shouldn't be > hard to implement. > this kind of implementation could also avoid sending any output to user > at all and instead > show a nicer warning message e.g. "sry, we have been slashdotted" or > something alike it. > > there is no nicer way i'm affraid. > > > nb! php style automatic "slaying" a thread isn't really such a great > idea cause > the jvm wouldn't have the knowledge how to correctly end the > "half-way-done" sql > queries or how to shut down some pools or anything else alike it. also > perhaps all the buffers > should be flushed or not flushed as your current app demands. > > Martin. > > Tony Claeys wrote: > >> Hi, >> >> Is it possible to set the number of seconds a servlet is allowed to run ? >> (something like set_time_limit() in php) >> >> Thanks in advance, >> Tony. >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by the new InstallShield X. >> From Windows to Linux, servers to mobile, InstallShield X is the >> one installation-authoring solution that does it all. Learn more and >> evaluate today! http://www.installshield.com/Dev2Dev/0504 >> _______________________________________________ >> Jetty-support mailing list >> Jet...@li... >> https://lists.sourceforge.net/lists/listinfo/jetty-support > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the > one installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Jetty-support mailing list > Jet...@li... > https://lists.sourceforge.net/lists/listinfo/jetty-support > |