public class UnsafeInc extends Thread {
    private static int count = 0;
    public synchronized void inc() { count++; }
    public void run() { this.inc(); }

    public static void main(String[] args)
        throws InterruptedException
    {
        Thread t1 = new UnsafeInc();
        Thread t2 = new UnsafeInc();
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        assert count == 2;
        System.out.println("count: " + count);
    }
}