A typical need when you work with data structures is to have an ordered list. Java provides
that has this functionality.
All the elements you want to add to
PriorityBlockingQueue have to implement the
Comparable interface. This interface has a method,
that receives an object of the same type, so you have two objects to compare: the one that is executing the method and the one that is received as a parameter. The method must return a number less than zero if the local object is less than the parameter, a number bigger that zero if the local object is greater than the parameter, and the number zero if both objects are equal.
PriorityBlockingQueue uses the