tag:blogger.com,1999:blog-5824660313967021040.post2948097784966220994..comments2022-03-26T08:56:28.677-07:00Comments on cfSearching: CFThread Must Die (Kill Bill) - Part 2Unknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5824660313967021040.post-67331061461791145282011-01-27T18:39:30.848-08:002011-01-27T18:39:30.848-08:00@Ben -
Done. Just keep in mind it is experimenta...@Ben - <br /><br />Done. Just keep in mind it is experimental code only. I have never used it on a production server. So caveat emptor ;) <br /><br />-LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-34252791203011237352011-01-26T21:23:09.082-08:002011-01-26T21:23:09.082-08:00@Ben -
Thanks for letting me know about the brok...@Ben - <br /><br />Thanks for letting me know about the broken link. Yes, there was more code. I believe I still have a copy of the experimental code somewhere. I will check tomorrow and post back.<br /><br />-LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-53874530419600045502011-01-26T17:13:05.565-08:002011-01-26T17:13:05.565-08:00I notice that the download of the code link no lon...I notice that the download of the code link no longer works. I am attempting to write my own Server Monitor, Active ColdFusion Threads interface that allows admin users to kill any cfthread that was started on ColdFusion stanard. Obviously the Server Monitoring API is not available in ColdFusion standard, so some alternate ability to terminate cfthreads is required. Do you still have the code you had available or was it just limited to the code as posted in the blog?Ben Reidhttps://www.blogger.com/profile/07365245685474286590noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-43590105304513074752009-11-02T03:45:04.146-08:002009-11-02T03:45:04.146-08:00@rad_g,
I wholeheartedly agree that whenever poss...@rad_g,<br /><br />I wholeheartedly agree that whenever possible threads should be allowed to run their course. Killing threads is not something to take lightly. I believe I was very clear about my feelings on that in Part 1 ;) However, I would not go so far as to say they should never be killed. The key is to shut them down gracefully, properly releasing all resources. So that the death of one thread death does not have a dangerous cascade effect on the entire server.<br /><br />Keeping in mind all of this was an experiment, one of the main reasons I started investigating alternatives to the low-level Thread.stop() is that it is _known_ to be unsafe. From everything I have read, it is very low level and can do a bit of hatchet job. So that led me to investigating, other more stable options.<br /><br />After a lot of testing and reasearch, I am pretty certain that Task.cancel() is what CF uses internally to terminate threads. Both when you call cfthread terminate and most likely when you kill a task via the Server Monitor. If that is indeed the case I feel relatively certain the internals take great care to properly terminate the thread in question, in as clean and stable a manner as possible. If it did not, I highly doubt thread termination would be implmentated as a feature in CF. Of course, I have not actually seen the source code. So this is all supposition on my part. But given that this is an internal method, I feel relatively confident Task.cancel() does a lot more cleanup than the basic axe-murdering job of Thread.stop().<br /><br />So while I agree that threads should not be terminated indescriminitely, sometimes it just needs to be done. Like the occaisional runaway thread that continues to chug along, consuming more and more resources. But I think the key is to do it cleanly, with a surgical instrument, not a rusty sledgehammer.<br /><br />-LeighcfSearchinghttps://www.blogger.com/profile/11564374520734454860noreply@blogger.comtag:blogger.com,1999:blog-5824660313967021040.post-73073025344222516102009-11-02T03:14:19.770-08:002009-11-02T03:14:19.770-08:00AFAIR killing threads forcibly is not the best ide...AFAIR killing threads forcibly is not the best idea. One should never do so. Threads should be asked to finish their job. Otherwise your app may leave the data in an intermediate state.rad_gnoreply@blogger.com