Unnecessary use of interrupt disabling
public void run(){
while(true){
//some deep logic
try{
Thread.sleep(5000);
}catch(InterruptedException){
//eating away the exception without taking any steps
}
}
}
So now the thread running this logic cannot be interrupted as it is eating away exceptions so it is called interrupt disabling, the only way to stop this would be to kill the program which is very bad as it can leave data structures in improper state.
Unnecessary use of lock acquisition and release
class Test{
private int counter = 0;
public synchronized void increment(){ counter++; }
public synchronized void decrement(){ counter--;}
//Unnecessary placement of synchronized block here
public synchronized void printString(){
//this method does not use counter so no need to use synchronized block
}
}