how to tell thread when to run code example Example: java check if thread is running Thread.isAlive()