I'm working with a company that produces a web application using struts with Java. I have been refactoring a lot of the code recently to tidy up the system. One technique I've been using is to move closing statements for streams, in finally blocks, of methods to a utility class. The utility class is static and has close methods for various types of streams. By doing this refactoring I save 5 lines of code every time a stream needs to be closed which has reduced code in some classes by 600 lines making it very favourable. However I'm worried by doing this that it may be possible to cause contention on those method if put into production.
I've only come across the concept of contention in multithreaded programming before which is why I'm not sure if this will cause problems in these instances.
Is this possible? or simply my misunderstanding of contention, static methods, web applications etc?
Thanks in advance, Alexei Blue.
Unless the static methods operate solely on their parameters and you don't try to concurrently close the same stream multiple times you should be fine.
Methods in general can be executed simultaneously. Synchronzation will always work on objects and thus contention should not occur if the objects you use in those methods are completely distinct.