On Sun, 30 Oct 2005 17:05:05 -0500, Kai-Uwe Bux <> wrote:
>asfwa wrote:
>
>> I'm new to C++ and I have some basic questions.
>>
>> I have written an app that does some network stuff in a worker thread. The
>> thread function requests something from the server, gets it and creates an
>> object from the server response. Does this thread terminate/stop/die as
>> soon as it completes its last line of code? Or do I have to do something
>> to kill it?
>
>The C++ standard does not mention threads at all (which makes it rather hard
>to even argue about the correctness of threaded applications in C++).
>Everything depends on the platform and threading library you are using. You
>should take your question to a newsgroup with that scope. Here, this
>question is off-topic.
>
****
There is clearly some confusion here. You are obviously confusing the kludges such as the
pthread library of Unix with true multithreading, and in any case, there is no "threading
library" in Windows (this concept should not be confused with the concept of the "thread
safe" libraries, which have nothing to do with implementing threading, only responding to
it), so the whole point of the above paragraph is completely irrelevant.
A thread executes in a stack. Stack semantics are well-defined by the standard.
****
>
>> I am used to coding Java so I am totally unsure of what I have to do to
>> "clean up" my variables/objects and free up memory etc. Should I use
>> "delete" for all objects I instantiate? How do I remove remove primitive
>> type variables?
>
>As a rule of thumb, use delete on exactly those objects that you created by
>means of new. You might consider using a shared_ptr<T> instead of raw
>pointers, as those will take care of deleting objects automatically for as
>long as you do not create dynamic data structures that have cycles.
>
>On the other hand, objects that you create by means of a definition will be
>destroyed when they go out of scope. This applies in particular to
>variables of built in types.
>
>
>Best
>
>Kai-Uwe Bux
Joseph M. Newcomer [MVP]
email:
Web:
http://www.flounder.com
MVP Tips:
http://www.flounder.com/mvp_tips.htm