import gov.nasa.jpf.jvm.Verify; import java.util.concurrent.Semaphore; public class testConcurrent extends Thread{ public static Semaphore sem; public static int in; static{ sem = new Semaphore(1); in = 0; } public static void main(String[] args) { testConcurrent t1 = new testConcurrent(); testConcurrent t2 = new testConcurrent(); t1.start(); t2.start(); } @Override public void run() { try { sem.acquire(); in++; Verify.assertTrue(in == 1); in--; sem.release(); } catch (InterruptedException e) { e.printStackTrace(); } } }