Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

SwingWorker job with notifyObservers and JTextArea feedback: Application freezes after JTextArea editing

Thread view: 
Claudius - 03 Jan 2005 10:43 GMT
Hi,
I am using a SwingWorker thread to run a Genetic algorighm(GA)
optimisation. I am showing a graph published by data that is sent from
the optimisation task using Observable / Observer mechanisms. The GA
job runs "long" (several minutes up to endless). I have two JTextArea
Fields on the GUI where i can change parameters used by the GA
optimisation.
When the GA optimisation runs and i start editing the content of any
JTextArea, the whole application freezes.
I tried to capture an event triggered by my editing of the content,
but no event is fired (as far as i am able to see) before the
application freezes.
Has anyone seen this behaviour before and maybe has an
idea/workaround?
Is there a better way to do such things instead of using observers?
Thanks for your time.
Regards,
Claudius
xarax - 03 Jan 2005 15:06 GMT
> Hi,
> I am using a SwingWorker thread to run a Genetic algorighm(GA)
[quoted text clipped - 14 lines]
> Regards,
> Claudius

1. The Swing text components are synchronized, but that
may cause issues between your worker threads and Swing.
If there are two or more threads attempting to call such
methods, then may be a freeze or deadlock.

2. The Observer/Observable things don't know how to
talk across threads. When the AWT Event Dispatch Thread (EDT)
calls a listener, that listener is running under the EDT
rather than your other SwingWorker thread.

A very safe way to handle such things is for listeners
to post a message (somehow) to your worker threads using
a synchronized event queue. When the worker threads want
to update the visual components, they must use
SwingUtilities.invokeLater(Runnable) to cause the update
to execute under the EDT.

You can use the new JDK 5.0 concurrent package or use the
Mutex package available at http://mindprod.com/products.html
to implement your own event queue for communicating between
your worker threads.

Signature

----------------------------
Jeffrey D. Smith
Farsight Systems Corporation
24 BURLINGTON DRIVE
LONGMONT, CO 80501-6906
http://www.farsight-systems.com
z/Debug debugs your Systems/C programs running on IBM z/OS for FREE!



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.