dcsimg
Abstract base classes with synchronized methods
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Uday_Kishore
Posted On:   Tuesday, October 28, 2003 11:18 PM

I have a abstract base class Base with a synchronized (non-static) method public synchronized void publish() . I have 2 concrete classes Derived1 and Derived2 , both of them extend from Base class. Both these classes override the publish method of the Base class. In the Derived1 class, the overriden version of publish method is declared as synchronized and calls super.publish() In the Derived2 class, the overriden version of publish method is NOT declared as synchronized and also calls super.publish() The entire application is heavily multi-threaded and there are   More>>

I have a abstract base class Base with a synchronized (non-static) method public synchronized void publish() .


I have 2 concrete classes Derived1 and Derived2 , both of them extend from Base class. Both these classes override the publish method of the Base class.


In the Derived1 class, the overriden version of publish method is declared as synchronized and calls super.publish()


In the Derived2 class, the overriden version of publish method is NOT declared as synchronized and also calls super.publish()


The entire application is heavily multi-threaded and there are 2 threads in the process which are getting into deadlock with one-another. One of them calls publish method on a Derived1 object. Another calls publish method on a Derived2 object.


Can anyone explain why this is happenning and what are the possible solutions?


Does marking a method of an abstract base class as synchronized cause some problems that need special addressing?

   <<Less

Re: Abstract base classes with synchronized methods

Posted By:   Edward_Harned  
Posted On:   Thursday, October 30, 2003 12:46 PM

Abstract is for the compiler. It is irrelevant to the execution machine.


Deadlocks go back to the first computer with multi-programming. Without seeing your code there is no way anyone (aside from superman) can know what is going on.


There are many profiling and debugging packages in the marketplace. For multi-threading applications, these are almost mandatory. Goggle for a list of commercial products. You really must narrow the question.

About | Sitemap | Contact