bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread activation bug


From: David Sugar
Subject: Re: Thread activation bug
Date: Tue, 11 Nov 2003 09:45:25 -0500
User-agent: KMail/1.5

Does the thread delete itself and have a "final" method implimented to do 
this?  Do you start the thread with "start()" or with "detach()".  If the 
thread is meant to be created and then run until it completes, followed by 
deleting itself, it needs to be started with "detach()", otherwise it will 
exit as an unjoined thread, and hence continue to use up a process or thread 
slot in the kernel process/thread tables even after exit.

On Tuesday 11 November 2003 05:21 am, Borja Pacheco wrote:
> Dear sir,
>
> I'd like to thank you this useful c++ library, which has help me a lot
> to introduce to develop c++ in linux.
>
> I've experienced some troubles with the class Thread, when implementing
> a multithreading server. This server acts in the following manner:
> 1. Listen new incomming tcp connections.
> 2. Create a new thread to serve the request
> 3. This thread is activated and start running
> 4. The thread finish its executions and it is destroyed.
>
> This method works rightly, at least for the first 1500 (more or less,
> I'm not sure for the number)  incomming connections. After these, the
> threads are created, but the method Thread.start() doesn't produce any
> effect.
>
> Here is a brief of my source code....
>
> void Thread_Listener::run() {
>         try {
>                 serverSocket = new TCPSocket (*ipAddres, tcpPort);
>
>                 while (serverSocket->isPendingConnection()) {
>                         thread_Service = new Thread_Service
> (serverSocket);
>                         thread_Service ->
> start();                                                 // THIS IS THE
> BUGGY LINE
>                 }
>         }
>         catch(Socket *socket) {
>                 <etc>
>         }
> }
>
> void Thread_Service::run() {
>
>         <Code for Executing
> Request>
>
>         exit();
>
> }
>
> Best Regards,
>
> Borja Pacheco





reply via email to

[Prev in Thread] Current Thread [Next in Thread]