From MAILER-DAEMON Wed Oct 31 18:31:03 2007
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1InM5X-0000zy-22
	for mharc-bug-commoncpp@gnu.org; Wed, 31 Oct 2007 18:31:03 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1InM5V-0000yF-IF
	for bug-commoncpp@gnu.org; Wed, 31 Oct 2007 18:31:01 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1InM5T-0000vZ-D6
	for bug-commoncpp@gnu.org; Wed, 31 Oct 2007 18:31:00 -0400
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1InM5T-0000vW-67
	for bug-commoncpp@gnu.org; Wed, 31 Oct 2007 18:30:59 -0400
Received: from 160.red-80-33-91.staticip.rima-tde.net ([80.33.91.160]
	helo=servidor.jocajica.com)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <jjcarles@terra.es>) id 1InM5S-0005lW-H3
	for bug-commoncpp@gnu.org; Wed, 31 Oct 2007 18:30:58 -0400
Received: from localhost (localhost [IPv6:::1])
	by servidor.jocajica.com (Postfix) with ESMTP id 5734CC845BD
	for <bug-commoncpp@gnu.org>; Wed, 31 Oct 2007 23:30:56 +0100 (CET)
From: Joan Carles Jimenez <jjcarles@terra.es>
To: bug-commoncpp@gnu.org
Date: Wed, 31 Oct 2007 23:30:54 +0100
User-Agent: KMail/1.9.6 (enterprise 20070904.708012)
MIME-Version: 1.0
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200710312330.55351.jjcarles@terra.es>
X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3)
Subject: Problem with Thread::join()
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 31 Oct 2007 22:31:01 -0000

Hi.

	I have the next code:

#include <cc++/thread.h>
#include <stdio.h>
#include <stdlib.h>

using namespace ost;

class MyThread : public Thread {
    
    public:
        MyThread();
        ~MyThread();
        
    public:
        int a, b, p, ms;
        double c;
        static int runs;
        
    private:
        void run();
        void final();
        
};

int MyThread::runs = 0;

MyThread::MyThread() {
}

MyThread::~MyThread() {
}

void MyThread::run() {
    c = 0.0;
        
    for(int i = a; i < b; i++) {
        if(i % 2 == 0)
            c = c + i;
        else
            c = c - i;
    }
    
    runs++;
    
    //sleep(ms);
       
    Thread::exit();
}

void MyThread::final() {
}

int main(void) {
    MyThread *th1 = new MyThread();
    th1->a = 1;
    th1->b = 10000000;
    th1->p = 1;
    th1->ms = 1000;
    
    MyThread *th2 = new MyThread();
    th2->a = 1;
    th2->b = 10000000;
    th2->p = 2;
    th2->ms = 500;
    
    for(int i = 0; i < 1000; i++) {                
      
        int p1 = th1->start();
        int p2 = th2->start();
        
        th1->join();
        th2->join();
    }
    
    fprintf(stdout, "-----> Runs %d\n", MyThread::runs);
    
    delete th2;
    delete th1;
    
    return 0;
}

When I compile and execute the code, the "th1->join()" and "th2->join()" non 
stop the threads. I use the commoncpp2 1.5.9 with openSUSE 10.3 64 bits. Can 
you help me? Thanks.

Regards.

-- 
Joan Carles Jimenez
jjcarles@terra.es



