This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Deadlocks  RSS feed

 
Florian Jedamzik
Ranch Hand
Posts: 47
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey it's me again;)

I'm currently trying out the Questions in the OCP Study Guide,
and I encountered an interesting question, where i "modified"
the Code a little bit.

See it here:




So I just coded a ScheduledExecutorService with a ThreadPool of 5.
Then I wanted tasks to be submitted every Second.

I am also currently explaining the Code to myself,
and I just wanted to know if I get it all right here.

To answer what is going on here, I'd say,
that there might be a deadlock at Runtime,
when one Thread acquires a lock on o1 in the
ScheduledFuture f1
and another Thread acquires a lock at the same
time on o2 in the ScheduledFuture f2.
This would be a Deadlock, am I right?


Kind regards
Florian
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36622
474
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. And deadlocks are bad .
 
Florian Jedamzik
Ranch Hand
Posts: 47
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha ok thank you!;)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!