used Thread.isAlive() instead of boolean