If your class is intended to be executed as a thread, then you can achieve this by implementing a Runnable interface. This belongs to the java.lang package.