How to use a thread in a subclass