wood burning stoves
The moose likes Java in General and the fly likes Synchronization issue? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Synchronization issue?" Watch "Synchronization issue?" New topic

Synchronization issue?

Ludmila Snova

Joined: Aug 31, 2006
Posts: 20
We have very weird issue that I cannot explain. However, I hope that someone can give some tips on it.
We have a web site that display documents and information related to those documents. Some users complain that when they open a page the date when documents were submitted is wrong (really old date is shown). And after page is refreshed the date is corrected. The problem is that this issue cannot be repeated easily. It happens in some specific situation. The application is running on WebSphere v 5 and it uses Struts framework. The date when documents were submitted is stored in the database (DB2) and dynamically retrieved from there when list of documents is requested.

I really appreciate any ideas.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Ludmila, our display name policy askes for something that looks like a real last name, no abbreviation or unorthodox punctuation. "S-va" looks to abbreviated to possibly be a real name; please edit your profile to spell out a complete last name. Thank you.

As for your question - yes, it does sound very much like this could be a problem due to threading issues, and proper synchronization is one possible solution. I suggest you look at where the date data is being stored - not just in the database, but the variable(s) that are used in your code when processing the data. Local variables are always safe from threading issues, but for instance variables, is there some way that two threads can gain access to the same instance? If so, you may need to use synchronization to prevent the instance data from being accessed concurrently. Or rewrite the other code so that instances are not accessible to multiple threads. Or change the instance variable to a local variable, if that's possible.

Many other solutions may be possible, but it's hard to be more specific without knowing a lot more about the details of your code. It's also possible that the bug has nothing to do with threads and synchronization, so don't get too committed to this idea, yet. But for the symptoms you describe, it's very possible that threads are the problem.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link: http://aspose.com/file-tools
subject: Synchronization issue?
It's not a secret anymore!