Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Thread.sleep()

Tags:

java

I want to disable possibility of using Thread.sleep() in a java project and use my own method instead:

sleep(int time, String info)

That will wait for given amount of time, and print info why is waiting necessary here.

Is disabling Thread.sleep() possible?

If yes, what's best method to do so?

like image 873
HappyAXE Avatar asked Apr 16 '26 21:04

HappyAXE


1 Answers

The best method would be to have hook on some static code analysis tool to mark build as failed if there are any invocations of Thread.Sleep().

You could probably configure SonarCube to do this.

like image 173
John Avatar answered Apr 21 '26 14:04

John



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!