You have to assign your thread to a variable and later call
join() on this variable like:
Thread t = new Thread() {
public void run() {
System.out.println("text");
}
};
t.start();
t.join();
This way you will wait until the thread finishes and just then continue.