Reputation: 226
I have a question to ask about Java Concurrency. I'm practicing Java Threading. What i do is create a simple interface which has a button and a JSlider. So when i click the button a variable will increase and the JSlider moving accordingly. Now I wonder if Swingworker is a right choice.
Upvotes: 1
Views: 205
Reputation: 205875
You may want to profile your code first.
Examples where a state change does not block the EDT: here and here.
An example where an action might block the EDT: here.
An example where an action will block the EDT: here.
Upvotes: 2
Reputation: 52498
You only need to use SwingWorker for long-running tasks. What you describe will be performed instantly. Therefore you can do this on the Event Dispatch Thread, where all ActionListeners are performed.
Upvotes: 4