I've got a method in which heavy processing is executed.
To avoid the GUI being frozen because of that, I execute this code
using a SwingWorker.
However, I need this code to execute in mutual exclusion; I need avoid
the same task being executing twice in background, so I use the
synchronized modifier.
If I use the current class object as the object which has the lock, my
GUI is frozen anyway, and the code I want to execute in background is
executed straight away.
I solve the problem using as a lock object for the synchronized
statement another object member in the class.
However, I don't understand why doesn't work:
synchronized(MyClass.this)
instead of:
synchronized(anObject)
I send the message to this list group because I think perhaps the
problem is related to the SwingWorker class.
I have the following code (I've simplified it):
class MyClass
{
...
private Object anObject;
SwingWorker myUpdater = new SwingWorker()
{
public Object construct()
{
synchronized(anObject)
{
// A lot of heavy processing.
...
}
}
public void finished()
{
}
};
myUpdater.start();
}
Thanks a lot.
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing