aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Do I need to synchronize method in the TableModel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Do I need to synchronize method in the TableModel?" Watch "Do I need to synchronize method in the TableModel?" New topic
Author

Do I need to synchronize method in the TableModel?

pkinuk Buler
Ranch Hand

Joined: May 22, 2009
Posts: 63
Hi all,

I created a class called ContractorTableModel, which extends AbstractTableModel. In the ContractorTableModel, I have an instance parameter, which is the array list of ContractorItem (ContractorItem encapsulated the contractor infomration like : name, location, number of stuff, rate, skill and customer ID).

The array list of ContractorItem is used in the getValueAt method:



I also have a method called updateContractorList. It is used to update the content of the array list of ContractorItem:



The method updateContractorList will be called when user perform search or update function through the GUI.

My question is: Do I need to synchronize updateContractorList and setValue methods in ContractorTableModel? Because I think if more than one thread calling the updateContractorList or setValue methods will cause problem. By the way, will the examiner perform multi thread to access the instance of ContractorTableModel?

Thank you in advance.




Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Pkinuk!

My question is: Do I need to synchronize updateContractorList and setValue methods in ContractorTableModel? Because I think if more than one thread calling the updateContractorList or setValue methods will cause problem. By the way, will the examiner perform multi thread to access the instance of ContractorTableModel?


No, there's no need to synchronize your updateContractorList method. You may assume that there will only be concurrency in your server/Data class. And I may be wrong, but I'd say that there are no multi-threaded tests in nothing but the server and the data class. I don't know, but even the server, this means that the assessors would have to create tests (like JUnit) from scratch, since there isn't a predefined interface for that (unlike the Data class). So maybe there are only multi-threated tests against the Data class.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
pkinuk Buler
Ranch Hand

Joined: May 22, 2009
Posts: 63
Howdy, Roberto Perillo!

Thank you for your fast replay!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do I need to synchronize method in the TableModel?