Files
codeql/java/ql/test/query-tests/BusyWait/BusyWaits.java
2018-08-30 10:48:05 +01:00

29 lines
625 B
Java

class BusyWaits {
public void badWait() throws InterruptedException {
while(this.hashCode() != 0)
Thread.sleep(1);
}
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);
}
}
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");
}
}
}