I've searched this along the way on the net but i haven't found an answer yet.. maybe someone of you guy knows this.
I'm developing a swing desktop like application; since I know that swing is not thread-safe (and if I call a method on a JComponent outside the EDT there is always the chance to get a deadlock with the EDT itself), I would like to have an exception thrown by the thread that is trying to call that method.. let me explain better:
suppose I have 2 threads: the EDT and a background worker ("BW").
If I call, for instance, JButton.setText()
, or JButton.setIcon()
within the BW there is a chance to get a deadlock with the EDT. Now I would like that when the BW calls JButton.setText()
and exception is thrown to indicate that I'm doing very wrong..
I see that C# on VS2008 does this by default (I don't know if there is a way to disable this behaviour, but I think it is very useful to detect bad code). Is there a way to achieve a similar effect in java?