It may never have crossed the designers mind for Thread to implement Comparable, but on the other hand things can get carried way out of hand if you start thinking this way. Why not put Comparable on every class, or at least those that make sense, for example Streams. After all a stream is a sequence of bytes, and we MAY want to compare streams to see if they are equal or if one stream is lexicographically less than another.
IMHO, this is a poor design, the tools are provided, and in the case of Java may have gone overboard, but you are free to build from them to incorporate all the ideas you mentioned above. If you take a look at what does implement Comparable, you'll see classes that should obviously be comparable and how they should be compared: Integer, String, Float, Date, etc. I would argue that the concept of comparing threads is not obvious at all, unlike the previously mentioned classes.
What if Thread did extend from Comparable and act as you suggest, then if I wanted to implement a type of scheduling system such as SJF (shortest job first, based on some state of the thread), the thread that should be "before" another thread is completely counter to the concept of the built-in priority.
|