Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronization issue?

 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic