 <p>If you are not well aware of executor service then the easiest way to achieve this is by using Thread wait and notify mechanism:</p> <pre><code>private final static Object lock = new Object(); private static DataType type = null; public static String getTypeOfData { new Thread(new Runnable() { @Override public void run() { fetchData(); } }).start(); synchronized (lock) { try { lock.wait(10000);//ensures that thread doesn't wait for more than 10 sec if (type == DataType.partial || type == DataType.temp) { return "partial"; }else{ return "full"; } } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } return "full"; } private static void fetchData() { synchronized (lock) { type = new SelectTypes().getType(); lock.notify(); } } </code></pre> <p>You might have to do some little changes to make it work and looks better like instead of creating new thread directly you can use a Job to do that and some other changes based on your requirement. But the main idea remains same that Thread would only wait for max 10 sec to get the response.</p>