Re: What's the connection between objects and threads?
On May 18, 4:56 pm, James Kanze <james.ka...@gmail.com> wrote:
What are the constraints concerning shutdown? If you don't have
any (i.e. the only way to stop the process is to kill it), then
your connection threads are basically fire and forget: you don't
really need to keep any trace of them (which means that you
don't have any "thread" objects). In fact, unless the server
needs to access shared in memory data, it may be preferable to
use processes instead of threads. (That's what a lot of
traditional servers do: FTP, telnet, etc.)
When you say processes do you mean different processes running
and communicating via files\pipelines\sockets and so on?
Often, you don't have to communicate anything while the child process is
running. On posix systems, fork() is used to create a copy of the process,
so the child knows everything the parent knew when the child was created.
1) Wont it just complicate things?
Actually, I consider it simpler, provided that you don't need to communicate
much after the child has been created. And it has the advantage that if one
of the porcesses crashes, that won't affect the others. In a threaded
program, everything will go down. That's especially important for servers,
which could often go completely without concurrency, but use separate
processes for improved stability.
2) Darren is supposed to submit his project to his prof\tester
usually spliting your projects (IMHO) to sub processes gives it a...
(maybe unjustified) scent of a bad design... Most of my professors
were fixed on the notion that an application is one process. (I think that
spliting your process to subs is a concept that is more acknowledged in
linux \unix platforms then windows.
Not sure what you mean by "splitting your process to subs". Unix
traditionally does many of the things it wants to do parallel with separate
processes. Threads aren't used very often.
Since process creation is much more expensive under Windows, similar
programs need to use threads for performance reasons.
AFAIK it's partially due to the reason that in linux you only
load your code once for all the instances of the application... or
Yes. Copying a process with fork() is very fast. You don't get much of a
performance boost from using threads.