Add exception handling for parallel threads