I'm just going through a Java course and several weeks before we went through multithreading where it was explained that when two(or more) threads work with the same object, the object has to be locked from all over threads except the one working with it.
Having a GUI I want to write some data from 2 threads to a JTextArea
should I bother about locking the object when one thread writes to it or this is handled already by the JTextArea
? If I should bother about it, how would I go doing this since I can not declare a Lock
inside the JTextArea
class definition? If I should not bother about this, does it stays the same with all swing object, if not, what are the exceptions?