add thread sample with graceful shutdown