void () { Listener listener1 = new Listener() { @Override public void foo() { myBuffer.append("[1]"); removeListener(this); } }; Listener listener2 = new Listener() { @Override public void foo() { myBuffer.append("[2]"); } }; final Listener listener3 = new Listener() { @Override public void foo() { myBuffer.append("[3]"); } }; addListener(listener1); addListener(listener2); addListener(listener3); String result = "[1][2][3]"; checkResult(result); }