public class myUIForm { //--------------------------------------------------------------------------------- //A button click or something calls DoFolderSync() // While the folder sync is happening, the UI is updated via the event handler(s). // Since it's running on a separate thread, our UI updates are visible/painted //--------------------------------------------------------------------------------- public void DoFolderSync(java.io.File folder1, java.io.File folder2) { FolderSync fs = FolderSync(folder1, folder2); // Register for FileCopiedEvents from fs fs.addFileCopiedEventListener(new FolderSync.FileCopiedEventListener() { @Override public void OnFileCopied(FileCopiedEvent evt) { //Do something with the event //Maybe updating UI elements } }); Thread t = new Thread(fs); t.start(); } } //------------------------------------------------------------------- // "implements Runnable" and the run() method are required // The run() method is called when the thread is "start"ed //------------------------------------------------------------------- public class FolderSync implements Runnable { @Override public void run() { try { SyncFolders(); } catch (Exception e) { /* TODO - Handle the exception */ } } //--------------------------------------------------------------------------- // The following is not required for the Runnable class or thread execution, // but gives a little context //--------------------------------------------------------------------------- java.io.File _folder1; java.io.File _folder2; public FolderSync(java.io.File folder1, java.io.File folder2) { _folder1 = folder1; _folder2 = folder2; } private void SyncFolders() { //Do something //Do something //Do something //Raise the OnFileCopied event //Do somthing } // IT WOULD ALSO CONTAIN THE OnFileCopied EVENT DEFINITIONS, BUT THAT'S ANOTHER SAMPLE }