bug-commoncpp
[Top][All Lists]
Advanced

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

Thread activation bug


From: Borja Pacheco
Subject: Thread activation bug
Date: Tue, 11 Nov 2003 11:21:51 +0100

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]