DCON
DCON

Reputation: 628

If I handle a GUI on a single thread that is not the EDT, is it still thread safe?

If I create a GUI on a different thread, and make sure that any updates that happen to the GUI occur on that thread and that thread only- is it then still thread safe? I know this would be difficult to ensure, so in a way I'm kind of asking: Is there anything special/different about the EDT compared to other threads?

Keep in mind I'm not asking about good practices or other solutions to this problem, I'm asking if, on a purely technical level, if you basically treated a thread like the EDT, would the GUI created on the new thread be safe to use?

Upvotes: 0

Views: 53

Answers (1)

Mykhailo Hodovaniuk
Mykhailo Hodovaniuk

Reputation: 521

It is not thread safe because your processes are not the only one that read/write UI element. JRE is also read and write but it does it via EDT. So even if you read/write in the single thread which is not EDT there are processes that do it in EDT - so you end up with one UI element, few threads, no synchronization.

Upvotes: 1

Related Questions