vicente.botet ha scritto:
BTW, why do you want to start the thread on the Init function and not on the constructor?
Hi, first, thanks a lot for the suggestion! The Init function was an example. My real class is a RS232 wrapper. I have to start a thread to continuous reading from ports, but only when the user call the open() method. I need the thread has a class scope because in the close() method where I close the thread and I call thread.join() void SerialPort::reading() { while (!_stoprequested) { reading.... } } bool SerialPort::open(void) { try { _thread.reset(new boost::thread( boost::bind(&SerialPort::reading, this)); } catch (boost::thread_resource_error e) { // Failed to create the new thread return false; } } bool SerialPort::close(void) { if (m_serial_port.IsOpen()){ // If the port is open, then the reading thread is _stoprequested = true; try{ _thread.join(); } catch (boost::thread_interrupted e) { //The thread is already stopped..do nothing } m_serial_port.Close(); } return true; }; So I think the pointer solution is good! Thanks again. Daniele.