remove system.exit and use boolean to shut down threads