Results 1 to 2 of 2
- 09-23-2011, 07:13 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 50
- Rep Power
- 0
Using thread pools with SwingWorker?
Hey all,
I am attempting to use multi-threading with Swing, and I am running into some problems. For one, I learned that you have to do everything on the EDT when working with Swing, and that using any other threads could lock up the UI.
However, I also started looking into SwingWorkers. I might be misunderstanding this, but it seems that the SwingWorker will start a thread, add it to its own thread pool, and and execute anything that it needs to dealing with the UI on the EDT.
I have 2 threads; one is designed to perform static animation by updating the BufferedImage that designates that particular object. The other performs dynamic animation, which simply changes the position of the image and then re-paints it at the new location. There is actually a third that controls stats, but that doesn't really have anything to do with the UI. Each thread is added to it's own thread pool, so that all processing power won't be focused on any one of the three types of threads.
So here is my question. Would it be possible to create three different thread pools that the SwingWorker can use? I know there is a way to increase the amount of threads that can be in the "active queue" or whatever, but is it possible to run the SwingWorkers as thread pools?
Sorry if I don't really understand how this stuff works, I am new to Java, very new to multi-threading, and very very new to multi-threading in Swing.
Thanks.
- 09-23-2011, 08:43 PM #2
Re: Using thread pools with SwingWorker?
I learned that you have to do everything on the EDT when working with Swing, and that using any other threads could lock up the UI.
Calling Swing methods/constructors on a Thread other than the EDT is not safe and can lead to intermittent, hard-to-debug glitches.
the SwingWorker will start a thread, add it to its own thread pool, and and execute anything that it needs to dealing with the UI on the EDT.
Would it be possible to create three different thread pools that the SwingWorker can use?
Sorry if I don't really understand how this stuff works, I am new to Java, very new to multi-threading, and very very new to multi-threading in Swing.
luck, db
Similar Threads
-
GLassFIsh connection pools
By videanuadrian in forum New To JavaReplies: 0Last Post: 12-07-2010, 12:00 PM -
SwingWorker or just plain thread
By elin in forum New To JavaReplies: 2Last Post: 07-09-2010, 01:26 AM -
In debug a javabean, how check it is giving to other component CORRECT data-DAO/pools
By lse123 in forum JDBCReplies: 22Last Post: 05-01-2010, 10:52 PM -
Using SwingWorker
By viking90 in forum New To JavaReplies: 1Last Post: 04-24-2010, 09:17 AM -
Swingworker or new thread
By cotarelo in forum Threads and SynchronizationReplies: 3Last Post: 03-24-2010, 06:59 PM
Bookmarks