RaspberryPi Sensor Control with pthread