• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deadlock - need helps

 
Chinh Tran Nam
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using applets for a customer's application. Sometimes, my IE hang and I sent the dump to Microsoft for their helps. Please see their answer below.

Could you give me a hint how to make threads running the viewpanel/Header.fireResizEvent() synchronized? I tried to put the synchronized keyword to the lotus/notes/apps/viewpanel/Header.setWidth method, is it correct?

Thanks

----------------------------------------------------------------------
Application code need to be modified for proper synchronization to avoid this deadlock and subsequent IE hang. Component.reshape() and Component.setBounds() are synchronized on Component object. Hence you need to make sure that threads running viewpanel/Header.firResizEvent() is synchronized so that it gets completed.

To summarize: Thread 0 -----> Thread 13 ------> Thread 0

<<<Thread 0>>>

[Mthd 4258c48h JIT java/awt/Component.reshape (IIII)V]
[Mthd 42c0798h JIT lotus/notes/components/NScrollbar.reshape (IIII)V]
[Mthd 42bc818h JIT lotus/notes/components/IrisScrollablePanel.EnableHorzScrollBar (ZLjava/awt/Component V]
[Mthd 42babe8h JIT lotus/notes/apps/viewpanel/ViewPanel.EnableHorzScrollBar (ZLjava/awt/Component V]
[Mthd 42bc598h JIT lotus/notes/apps/viewpanel/ViewPanel.updateValues ()V]
[Mthd 42bb278h JIT lotus/notes/apps/viewpanel/ViewPanel.headerResized (Llotus/notes/apps/viewpanel/HeaderEvent V]
[fast-interpreted] lotus/notes/apps/viewpanel/Header.fireResizeEvent (I)V
[Mthd 42cff38h JIT lotus/notes/apps/viewpanel/Header.setWidth (I)V]
[Mthd 42bbb48h JIT lotus/notes/apps/viewpanel/ViewPanel.resize (II)V]
[Mthd 42b68e0h JIT lotus/notes/apps/viewapplet/ViewApplet.reshape (IIII)V]


<<<Thread 13>>>

[fast-interpreted] lotus/notes/apps/viewpanel/Header.fireResizeEvent (I)V
[Mthd 42cff38h JIT lotus/notes/apps/viewpanel/Header.setWidth (I)V]
[Mthd 42bbb48h JIT lotus/notes/apps/viewpanel/ViewPanel.resize (II)V]
[Mthd 42b68e0h JIT lotus/notes/apps/viewapplet/ViewApplet.reshape (IIII)V]
[Mthd 4259308h JIT java/awt/Component.setBounds (IIII)V]
[Mthd 425d7f8h JIT java/awt/BorderLayout.layoutContainer (Ljava/awt/Container V]
[Mthd 4257128h JIT java/awt/Container.layout ()V]
[Mthd 42570f8h JIT java/awt/Container.doLayout ()V]
[Mthd 42572a8h JIT java/awt/Container.validateTree ()V]
[Mthd 4256ee8h JIT java/awt/Container.validate ()V]
[Mthd 4256378h JIT java/awt/Window.dispatchEventImpl (Ljava/awt/AWTEvent V]
[Mthd 4258468h JIT java/awt/Component.dispatchEvent (Ljava/awt/AWTEvent V]
[Mthd 4284e98h JIT java/awt/EventDispatchThread.run ()V]
[ November 08, 2004: Message edited by: Chinh Tran Nam ]
 
Henry Wong
author
Sheriff
Posts: 22524
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you give me a hint how to make threads running the viewpanel/Header.fireResizEvent() synchronized? I tried to put the synchronized keyword to the lotus/notes/apps/viewpanel/Header.setWidth method, is it correct?


Synchronization is *not* a silver bullet that can solve your deadlock problems. In fact, it was probably synchronization that caused it in the first place. You really need to know what you are doing...

But to answer your question. Making Header.setWidth() synchronized will absolutely not work. This deadlock is caused by a conflict with two locks -- with the component and header objects. You need to prevent it -- which can't be done without involving both objects.

A quick and dirty fix is to establish a higher order lock. Create a new lock, that both the component and header objects will grab prior to grabbing their own locks. This will seriously affect concurrency, but is the quickest way to fix your problem.

As a side note, it looks like both of these objects are system/library classes (from Sun and Lotus). Be careful with changing code that you don't control.

Henry
[ November 09, 2004: Message edited by: Henry Wong ]
 
Chinh Tran Nam
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry,

Synchronization is *not* a silver bullet that can solve your deadlock problems. In fact, it was probably synchronization that caused it in the first place. You really need to know what you are doing...


So, another option is I remove the lock on Header object. Is it posible?

A quick and dirty fix is to establish a higher order lock. Create a new lock, that both the component and header objects will grab prior to grabbing their own locks. This will seriously affect concurrency, but is the quickest way to fix your problem.

As a side note, it looks like both of these objects are system/library classes (from Sun and Lotus). Be careful with changing code that you don't control.


Of course, I cannot change code for Sun's classes but I can for Lotus'. Could you tell it more clearly how to place a higher order lock for the component and header objects?
[ November 09, 2004: Message edited by: Chinh Tran Nam ]
 
Henry Wong
author
Sheriff
Posts: 22524
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, another option is I remove the lock on Header object. Is it posible?


Absolutely NOT. Synchronization was originally done for a reason. You can't just removed them. Deadlock is caused by improper synchronization, you need to correct it, not remove it.


Of course, I cannot change code for Sun's classes but I can for Lotus'. Could you tell it more clearly how to place a higher order lock for the component and header objects?


Unfortunately, with the technique I am suggesting, you have to change both. And it will not be easy.

You need to rewrite both classes, so that they have a different names. Then you write your own version of your classes that replaces the two classes. Then you need to create a common object that both of these classes can access.

Object HigherOrderLock = new Object();

Your replacement classes must grab this lock for all the synchronized methods, and then call the original version, something like this.

 
Henry Wong
author
Sheriff
Posts: 22524
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm... don't know what happened to my last post:

Anyway, the code should look something like this:



You need to do this for all problem methods, for both classes. And you need some way to make sure that both classes use the same higher order lock. And for this, you will lose concurrency.

IMO, I don't think it is worth the effort. You may want to serious reconsider your algorithm.

Henry
[ November 09, 2004: Message edited by: Henry Wong ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!