• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

deadlock

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!


http://www.java-samples.com/showtutorial.php?tutorialid=307

This is an example of deadlock, But I can't understand where is the deadlock in that code?

The deadlock happened when two thread want to access one resource, But I don't such thing in that coe

Please guide me


[HENRY: Formatted Code]
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

abalfazl hossein wrote:
http://www.java-samples.com/showtutorial.php?tutorialid=307

This is an example of deadlock, But I can't understand where is the deadlock in that code?

The deadlock happened when two thread want to access one resource, But I don't such thing in that coe



I think your definition of deadlock is incorrect. There are actually many ways to deadlock, and the example is defining it as and showing as... A deadlock can occur when two threads are trying to grab two different locks. They each grab one of the locks, and then wait for the other lock. In this case, the deadlock is occuring because neither can grab the other lock because it is owned by the other thread -- and neither will release the lock that they did grab because they are both in a wait state waiting for the other lock. This condition can't be resolved, hence, deadlock.

Henry
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, As you define the deadlock. Now Please tell me how deadlock happened in that code?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

abalfazl hossein wrote:OK, As you define the deadlock. Now Please tell me how deadlock happened in that code?



You can't see it? It is pretty clear.... plus the code is loaded with print statements so that you can follow it.

Try it. Run the code.... And if you still don't see it, describe what you do see, and we'll give you some hints on where you went wrong.

Henry
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is only one lock fro every object.

Then when Mainthread takes lock of class A,Racing thread couldn't take lock of class A.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can see a full thread and monitor cache dump by pressing CTRL-BREAK on a PC (or CTRL-\\ on Solaris).



http://www.java-samples.com/showtutorial.php?tutorialid=307

I use Netbeans,I press CTRL-BREAK while I run that program , but I didn't see anything.

I search and find about Netbeans:

http://profiler.netbeans.org/

But I didn't see any link to download this add on....

and don't find that on Netbeans....

I also try SendSignal in cmd....But unlucky....I don't know how to find the ID of process that is belongs to program that I run .....

I want to see thread dump. What is the simplest way?
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The path to a secure application ,IBM

e. Race conditions
Two processes might share control or data. Race conditions is
the term applied to compromising this sharing, which typically
results from synchronization errors, when the potential exists
for process conflicts, and a resulting vulnerability. A typical
exploit interrupts a pair of sequential calls that are meant to be
performed automatically without interruption by another
thread or process on the machine with a third process.

One example is the combined checking of access rights to a
file, followed by a subsequent call to write or read that file. By
interrupting the process between the two calls, an attacker can
rewrite or modify the file because this behavior is expected.
The attacker can place inappropriate information into a file,
or perhaps access an inappropriate file



May someone explain more about the example?
 
reply
    Bookmark Topic Watch Topic
  • New Topic