UnsafeSequence seq = new UnsafeSequence(); // both thread instances share same object Thread t1 = new MyThread(seq); Thread t2 = new MyThread(seq); t1.start(); t2.start(); // run method for above `MyThread` class: public void run() { while(some condition) { // some work System.out.println(seq.getNext()); // sequence is unpredictable } }