Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing and deadlock  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Concurrency�
In Practice
Another factor leading to deadlock in multithreaded GUI framework sis the prevalence ofthemodel view control(MVC)
pattern.Factoring user interactions into cooperating model,view,and controller objects greatly simplifies implementing
GUI applications, but again raises the risk of inconsistent lock ordering. The controller calls into the model, which
notifies the view that something has changed.But the controller can also callin to the view,which may inturn callback
into the model to query the model state. The result is again inconsistent lock ordering, with the attendant risk of
deadlock


In this statement, Deadlock is discussed in Swing,It is said MVC can cause deadlock, May you you give me real example about that?

Please explain more about that
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl: MVC does not cause deadlock more than other program structures.

The important point is when a code segment locks more than one object, the order
in which the locks are taken can make a difference. In thread_A, if lock_1 is taken,
followed by lock_2, thread_B should use the same order; take lock_1 and then lock_2.

Deadlock occurs if thread_A is holding lock_1 and tries to get lock_2 when it is already
held by thread_B (because locking in thread_B is out of order). I hope this helps.

Jim ...
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

Please give me an example that describes that statement about MVC and deadlock that I told in my first post
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still wait for answer....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!