public class X { void f(Object action) { if (action instanceof Runnable) { ((Runnable)action) } } }