关于java swt的问题 点击按钮,弹出一个带Text的对话框,输入一个字符串,然后关闭对话框,同时保存字符串

因为之后要对保存的字符串做一些操作,要暂时停止后面代码的执行,但是不知道该怎么停止。。。
button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if(linked==true)
{
if(send_command==false)
{
send_command=true;
CommandShell comShell=new CommandShell();
comShell.open();
synchronized(command)
{
if(command==null)
try {
wait();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
button1.setText("发送文件");
sendCommand sr=new sendCommand();
Thread sct=new Thread(sr);
sct.start();
}

相关的代码大概这些吧,因为初学java,多线程啥的一头雾水,synchronize和wait也不知道用的对不对,唉,头疼
thread.wait()