Files
codeql/java/ql/test/query-tests/BusyWait/BusyWaits.java

30 lines
648 B
Java

class BusyWaits {
public void badWait() throws InterruptedException {
while(this.hashCode() != 0)
Thread.sleep(1); // $ Alert
}
public void badWait2() throws InterruptedException, CloneNotSupportedException {
while (this.hashCode() < 3) {
for (int i = 0; i < this.hashCode(); this.clone())
Thread.sleep(new String[1].length); // $ Alert
}
}
public void noError() throws InterruptedException {
while(this.hashCode() < 0) {
this.wait();
this.notify();
if (1 < 2)
Thread.sleep(2);
}
}
public void noError2() {
while (this.hashCode() < 0)
synchronized(this) {
System.out.println("foo");
}
}
}