Java synchronizing static list ?

Posted by JavaUser on Stack Overflow See other posts from Stack Overflow or by JavaUser
Published on 2011-01-16T06:04:38Z Indexed on 2011/01/17 0:53 UTC
Read the original article Hit count: 124

Hi,

In a Java class , i am having a static list so this list is shared across all the objects of this class.The business logic in this class will run periodically which is invoked by some method with out passing instance parameters.Now I want to invoke this run method based on the list(I will add some vales into this list based on JMS) ,this list may empty sometimes and after finishing the run , i am emptying this list.Now my question is , whether I need to synchronize this list or not?

Also let me know is there any other way to pass value in one object instance(Thread1) to other object instance (Thread2) other than having Static variable(static list)?

Thx

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading