handle long running tasks and thread death with timeouts