You can create your own subclass for a thread that performs the required check in the constructor (s) or in the start method.
To ensure that the executable code uses your own thread class, you must load the code using your own custom class loader, and this class loader just picks up any request for the java.lang.Thread class and instead produces your own class (this concept could be extended to other classes).
Warning: implementing this rule is not trivial.
Durandal
source share