| Web News |
New Players Reshape Wireless Germany Prices for mobile-phone calls are falling fast in Germany, threatening to introduce an era of slim profits for carriers in a country that is among the world's slowest to embrace wireless technology. For much of the past 15 years, Germany's mobile market has been marked...
GlobalMedia rebrands as bigmouthmedia in Germany European search marketing agency GlobalMedia has re-branded as bigmouthmedia in Germany. This announcement follows the recent rebrand of GlobalMedia's Nordic and French offices.
German security shop challenges anti-hacker laws Fed up with the “ambiguity and confusion” surrounding Germany’s controversial anti-hacker laws, a private security research firm has put its hacking tools back online as part of a public test of the interpretation of the new law. n.runs AG, a well-known penetration testing...
|
|
09.27.07
Questions About CFThread
By Raymond Camden
Nathan Smith sent me some questions on CFThread.
I've broken up his email and bit and have commented with my opinions. I'd like to know what others think as well. CFThread is brand new to the language. Just like we are still debating the best way to use CFCs, I think we have a long road ahead of us deciding what is 'best practices' for this feature. Anyway - Nathan's email:
In your blog posts, you mostly are using it to send some time-intensive tasks away from the page thread(user). This is done to return "control" to the user faster and make the application appear to run faster.
Actually that isn't always true. You can fire off threads and not wait for them to return. This does then result in the user getting a result a lot quicker. (Which you can kind of do in older versions of ColdFusion with the CFFLUSH tag.) You may choose though to wait for your threads to finish. This is done with the JOIN action:

Most of the examples I have seen so far use cfthread to enclose some simple, operation or a single tag. Is it safe to enclose large blocks of code inside a thread?
Well I think the answer here is "it depends." I don't think there is any simple answer as to how much code should be inside a cfthread. I'd probably try to keep it small just because there is less chance to screw up (more on that later).
I have an application that is basically two parts - interface and core. At one point I do a cfexecute on the core, while the user waits. could I put a cfthread around this type of thing to protect the user from breaking their core-requests and processes? How do I know if all the stuff happening in the core will be "thread-safe"? Ah and here is where things can get nasty. Let's assume that when a user requests foo.cfm, you fire off a thread and then tell the user 'your process is running.' If the user reloads, what should happen? Should the process run again? If not - then you need some way to track the thread. You can use the Application scope. Before the process runs, check for Application.ImDoingX. If true, then don't run the thread again. Inside your thread you need to set ImDoingX back to false when done. Problem is though - what happens if the process dies and never sets it to false? You may want to also record when the process began and do some kind of sanity check. If it has been running for 30 minutes then you may want to just assume it died.
Continue reading this article.
About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long
time ColdFusion user, Raymond has worked on numerous ColdFusion books
and is the creator of many of the most popular ColdFusion community web
sites. He is an Adobe Community Expert, user group manager, and the
proud father of three little bundles of joy.
|