I'm learning how to interfere with Arduino with help of COM and Java. As COM library I use jSSC. I have a question about receiving data from COM by pushing some JButton in my frame. As I release the button I should start a loop getting data from COM, which gets values every 25 ms. Just some floats.
How can I break this loop by pressing another JButton. For instance, we have two of them: Get data from COM and Stop. First should launch the loop, second - break it.
Maybe you can recommend some better solution to it.
The typical approach to this would be to do the long running task in a SwingWorker
. Call cancel(boolean)
if the 'stop' button is activated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.