Run a method in a new thread of the plugin
How do I run a method in a new thread in the background so it doesn't block the plugin GUI or interfere with other Geneious functionality? I've tried using new Thread(), using SwingUtilities, and using all the variants of ThreadUtilities (I think), but none of those seem to run the task in the background like I need. The method I'm running can take up to 20 minutes to run, and it throws timeout errors because it conflicts with shared database updates if it runs on the main thread. Also, the GUI needs to update after this method has run, and that update doesn't seem to work in a new thread either.
-
Normally this is achieved by implementing a DocumentOperation which will handle running the performOperation method in a background thread with an appropriate progress dialog to keep the user informed. If you are executing code elsewhere then you should be able to use standard Java thread calls like below. If this is not working for you, can you describe the behaviour you see in more detail?
new Thread(() -> {
//perform work
}).start();0
Please sign in to leave a comment.
Comments
1 comment