Thread Safety and Shared Resources