Results 1 to 3 of 3
  1. #1
    rajakumar.tu is offline Member
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Default do static methods cause synchronization problems

    can i know weather a static method say a dao method can cause synchronization problems .

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by rajakumar.tu View Post
    can i know weather a static method say a dao method can cause synchronization problems .
    A static method can have a block that synchronizes on any object just like any non-static method can. If you don't explicitly use an object but make the entire method synchronized, a static method will synchronize on the class object.

    kind regards,

    Jos

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    The answer is yes. Synchronization problems come from modifying an object's instance variables, or class variables, from two threads. As Jos said, use synchronization techniques to avoid the problem.

Similar Threads

  1. Replies: 8
    Last Post: 04-17-2012, 12:00 AM
  2. Recursion with static and non static methods
    By sh4dyPT in forum New To Java
    Replies: 14
    Last Post: 03-27-2009, 07:56 AM
  3. Static methods
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-04-2007, 06:56 PM
  4. Synchronization problems
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 02:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •