I was just wondering if it is still necessary to ensure synchronicity in an invokeLater() Runnable.
I am encountering deadlock and need to overcome it while maintaining concurrency.
Would this be an example of good code?:
private String text;
private void updateText()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
synchronized(FrameImpl.this)
{
someLabel.setText(text);
}
}
});
}
Sorry for the rather bad example, but we must assume that text
is being modified by different threads, cannot be injected, and is reliant on a correct value.
Is this the proper solution or will I unintentionally create a deadlock problem by sending synchronized code off into an unknown context..?
Thanks.