java - Thread output listener -
i need make thread start @ swing button push , wait input rs232, process , return string variable. question how that?
it should that:
string myoutputstring = waitforinputthread(); or if possible in swing panel make listener if waitforinputthread send interrupt (for example, if rs232 input update list of items in jtable).
could give me clues, tutorials, examples etc ?
to avoid blocking event dispatch thread (which thread updates gui), start new thread interact rs232. swingworker class 1 option, can use normal thread.1 blocking edt causes gui freeze, must never used lengthy tasks.
once result computed, update gui using swingutilities.invokelater(). ensures gui change occurs on edt.
1 i tend find normal threads executed via executorservice better unit testing (as can write executorservice executes runnable, avoiding nasty thread issues junit).
Comments
Post a Comment