Why is timeunit Java util. Members of concurrent?
Java's timeunit enumeration is useful for many different tasks related to time, not just concurrency; And other time related classes like date are Java Part of util So why is timeunit Java util. Members of concurrent?
Solution
In addition to providing methods to use time with different granularity, timeunit also provides thread aware methods such as timedjoin:
Public void timedjoin (thread, long timeout) throws interruptedexception
I think this class originated from helping common parallel programming tasks, such as deferred execution Because it has two different functions (managing time granularity; applying time concepts to thread problems), this violates the single responsibility principle
Considering the practicability and popularity of timeunit external concurrent code, a more perfect solution may be a Java util. Timeunit enumeration, used to manage time granularity, and a separate Java util. The concurrent class is used for applications in threads