You know what thread safety is, right? If not, there is a simple example below. All classes must be thread-safe,…