package com.app; public class Main { public static void main(String[] args) { Main main = new Main(); System.out.println(main.read("ololo")); System.out.println(main.read("pepepe")); } public String read(String name) { Reader reader = new Reader(name); Thread thr = new Thread(reader); thr.start(); try { thr.join(); } catch (InterruptedException ex) { } return reader.getResult(); } private class Reader implements Runnable { private String name, result; public Reader(String name) { this.name = name; } public String getResult() { return result; } @Override public void run() { try { // Имитируем длительные выполнения. Thread.sleep(2000); } catch (InterruptedException ex) { } result = "Updated result from " + name; } } }