Re: Threading in web Application
On Apr 24, 4:59 am, Lew <l...@nospam.lewscanon.com> wrote:
Ershad wrote:
I have a Question about Threading In webApplication,
J2ee Support threading! Is it Usefull for web appliction?
if you know php does not support Threading without any problem in web
application
JEE containers are multi-threaded, so generally web apps do "support"
threading, however it is extremely bad practice and a source of multiple bugs
for the web-app developer to explicitly manipulate threads.
It is better to write thread-safe code but not to spawn any threads of your
own, in web-app development.
--
Lew
Why is that Lew? Concurrency programming is trickier than serial
programming, but since your webapp is possibly concurrent anyway, you
should learn how that effects your design...
Knowing this, you should also know what is safe to do as far as
spawning your own threads. In general, this means using proper
synchronization constructs, and limiting the number of threads created
so that they don't cause a problem.
There are cases where spawning multiple threads for a single request
make sense. If you have a request that needs to access two separate
high-latency data sources, it makes sense to do them concurrently.