Hi ranchers,
Whats happening in the following program, why my assert stmt is not working.......
public class Threads implements Runnable {
private int x;
private int y;
public static void main(
String[] args) {
Threads that = new Threads();
(new
Thread(that, "first")).start();
(new Thread(that, "second")).start();
}
public void run() {
for (int i=0;i<10;i++) {
x++;
y++;
assert(x!=y): "x=" + x + ", y = " + y;
System.out.println(Thread.currentThread().getName() + "x=" + x + ", y = " + y);
}
}
}
//If the assert condition false then it should throw an AssertError am i correct
Please try this and give reply
thanks in advance