Improving Nucleo thread and semphore; adding new member function attach().