Is it Synchronized?
3 posts in topic
Flat View  Flat View

Posted By:   Aladdin_Mouhaimeed
Posted On:   Wednesday, April 23, 2003 08:59 AM

I want to use some method in a JSP page, this method takes an array as an input and gives an array as an output, I mean that this method could be invoced simultaneously many times but everytime with different data in input and output; sould this method be sinchronized?

Is it enough that it works on its own data everytime to have no conflicts?

Re: Is it Synchronized?

Posted By:   Prashanth_Kid  
Posted On:   Monday, April 28, 2003 06:40 AM

Moreover, you need to make it synchronized if the method is a static method. Or else, it is better not making it synchronized.

Re: Is it Synchronized?

Posted By:   Stephen_McConnell  
Posted On:   Thursday, April 24, 2003 05:35 AM

The only time you need to worry about synchronization is when the method could be changing the same piece of data as another method or another call of this method at the same time.

If you are taking the array in and creating a copy of it, then working on that data, then you should not have any problem.

If, however, this instance of the array may be accessable by another thread, then you may want to synchrnoze the copy block (just the portion when you copy to another array), just because you don't want someone to change the array as you copy it.

Thread synchronization topics can be a pain; and the can slow you code down and create gridlock, but careful planning can prevent lots of debugging heartache.

Stephen McConnell

Re: Is it Synchronized?

Posted By:   Jeanne_Boyarsky  
Posted On:   Wednesday, April 23, 2003 05:36 PM

No, it should not be synchronized. This would slow down your application for no reason. Since the data is different, it is okay to have different instances of the method running at the same time.
About | Sitemap | Contact