I've tried to implement the first solution but the compiler says me i've re-defined the Samplingthread class
Show your code.