I am writing a variation of the Multiple Sleeping Barber problem in JAVA, where each customer has a time of tolerance for waiting for the barber and a specific time for having their hair cut, plus in addition to sleeping when there are no customers, each barber sleeps after cutting the hair of a certain number of customers for a specific time.
Due to the variation I feel the need for a global variable which keeps track of the time.
My question is, will I face any problems if I use a Global class with static fields for tracking time? I have read that if my global class becomes "unloaded" the value would become null; when does this happen and will it be an issue in my case? If it is, what other options do I have?
(I would increament time in a "while" loop in my main class which extends Thread and the Customer and Barber classes which also extend thread will only need to read it).