Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do I need to synchronize method in the TableModel?

 
pkinuk Buler
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pkinuk Buler
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Roberto Perillo!

Thank you for your fast replay!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic