Learning to use threads in class