Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About using Swing components in SCJD exam

 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I read Chatper 4 of Monkhouse book, Swing is not thread safe and it is recommended that a Swing component should be accesed by only one thread.
As far as the exam is a concern, if two threads try to write a string into a JTable cell, should I still synchronized the JTable object?
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Swing client is such a simple application. There is no need to have a multi-threaded approach. So it's not an issue at all.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Roel De Nijs.

Helen Ma wrote:As far as the exam is a concern, if two threads try to write a string into a JTable cell, should I still synchronized the JTable object?

Well, is it really going to happen? The chances are very high that the String will come from server as part of remote object, and your client will write that String in JTable. I don't see any reason why your client should do it in multi-threaded way.

And secondly, the moment you open another client, there will be completely new GUI, which means the JTable also would be different one.

So, there's no need to worry about thread-unsafety of swing components.

I hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic