Adding try-block to catch IllegalThreadStateException

Added try-block to catch IllegalThreadStateException