Dear All, The create method above is not thread safe since there is no synchronization on the method. I have opted to leave it as it is and mention in the "choices.txt" what will happen if two thread tries to create a record on the server; please notice this is applicable when the application is running in a network mode. Now I can add a synchronization method and it will prevent any two threads from entering the method at same time ; hence overriding each other. Any way, my point here is to explain the uncertainty in this method rather then to make the method perfect. I need your valuable feedback concerning "KNOWING THE THREAD SAFETY ISSUES". I wanted to make a point in my �choices.txt�
This issue is depending on your architecture more precisely on your server architecture, by example you choose to have a more data Data instance(I here I presume that the Data class owns the create(String) method)then the synchronized the useless. What is really important is that the file hander - the class which read/write your db file has all the important method synchronized. If two threads access in the same time your create method and and your "physical write" is synchronized then you can let the create unsynchronized. And a final note, may be I am wrong, is not such a good idea to have the Data methods synchronized because the the LockManager is responsible for the "thread handling".
[ September 22, 2006: Message edited by: Mihai Radulescu ] [ September 22, 2006: Message edited by: Mihai Radulescu ]