multithreading - Java sharing an object between threads -


i have database object stores objects in various data structures. several threads access database, database not date. if change name of object in 1 thread, change reflected in other threads if have not accessed object already. if add new item in 1 thread, threads able view item.

i've tried declaring database object volatile, problem remains , i'm out of ideas...

thanks!

edit: issue traced down not calling .reset() on objectoutputstream

you need synchronize access database object instance.

in java there 2 two basic synchronization idioms:

  • synchronized methods (apply synchronized keyword methods accessing database object instance)
  • synchronized statements (wrap code accessing database object instance inside synchronized block).

more details


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -