if (display.isValidThread())
if (display.getThread().equals(Thread.currentThread()))
  public Track getSelectedTrack()  {    final Track[] answer = new Track[1];    final Object[] monitor = new Object[1];    Runnable r = new Runnable() {      public void run() {        try {          int index = tblSongs.getSelectionIndex();          Track track;           if (index < 0)            answer[0] = getPlayingTrack();          else            answer[0] = getTrackByTableItem(tblSongs.getItems()[index]);        }        finally {          if (monitor[0] != null)            synchronized (monitor[0]) {              monitor[0].notify();            }        }      }    };    if (display.isValidThread())      r.run();    else {        // If this isn't the SWT event thread, then we must delegate to it,        // because we might be called from a thread other than it, such as        // the remote control thread.      monitor[0] = new Object();      synchronized (monitor[0]) {        display.asyncExec(r);        try {monitor[0].wait();} catch (InterruptedException e) {};      }    }    return answer[0];  }