• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About using Swing components in SCJD exam

 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic