Add exception handling in threads for encryption/decryption