Wednesday 15 May 2013

java - Design issue- should use seperate thread for GUI? -


I'm making a small software in Java with GUI. I have an algorithm that runs continuously (approximately 24 / 7) (I have a stop / start button in GUI) This algorithm should update a list and display a log on GUI. The question is whether I should make a separate class or thread for this process (1) If the answer is yes - should I transfer the GUI elements which I should update as the parameter of that process? Will it cause problems in updating the GUI? 2) If not, how should I design it?

Many thanks in advance!

You should use heavy work swingwalker for these situations You have a good article here. If your algorithm takes 5 sec for example and you run guise in the same thread, then you need this reason, to free up your view until it is finished is.

BTW Event Dispatches Thread to all GUI components, so they do not need to update to another thread because they are not updated.

No comments:

Post a Comment