Video is locked.

Unlock the full course today

Join today to access over 15,000 courses taught by industry experts or purchase this course individually.

Advanced Java Programming

Avoiding thread deadlock

From the course: Advanced Java Programming

Start my 1-month free trial
  • Course details

    Want to get more out of the Java language and platform? In this platform- and framework-neutral course, instructor Bethan Palmer digs into some of the language’s more advanced features, helping you expand your programming skills as she equips you with techniques you can use when building applications anywhere Java is used: in web, mobile, and desktop applications. Bethan covers a variety of topics, including generics, working with the Collections Framework, and functional programming. Plus, learn about I/O in Java, working with files and directories, and structuring applications using the modular system available in Java.

    Instructor

    • Click here to view Bethan Palmer’s instructor page

      Bethan Palmer

      Software Developer and Java Champion

      Bethan Palmer is a developer who loves technology and has a master's degree in computer science.

      For her day job, Bethan is a Java programmer and the product manager for a Java PDF library at IDRsolutions. She gets to spend a lot of time writing and refactoring code, as well as deciding on product strategy and road maps.

      She also spends much of her time attending conferences and is a regular speaker at Oracle Code One and NetBeans Days. She manages and writes articles about Java, technology, the books she's reading, and conferences she's attending on the Java PDF blog.

    Skills covered in this course

  • Learn advanced Java programming

    - [Narrator] A deadlock can occur when two or more threats get blocked forever. For example, this can happen when two threats are both waiting for resources held by each other. In this example, I am simulating a situation with two cooks in a kitchen. Imagine if both cooks wanted to mix some ingredients, so they both need a spoon and a bowl. However, there is only one spoon and one bowl. The first cook picks up the spoon and at the same time, the second cook picks up the bowl. Now both cooks are waiting for the other one to put down their object so they can pick it up. This is a deadlock. To simulate this, I have a class called kitchen with two objects called spoon and bowl. Then in the main method, I have two threads which represent the two cooks. So I have called them cook one and cook two. Inside the first thread is a synchronized block. A synchronized block or synchronized statement is a section of codes that only one thread can enter at a time. This means that you can have…

  • Practice while you learn with exercise files

    Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.

    Download the exercise files for this course. Get started with a free trial today.

  • Download courses and learn on the go

    Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.

    Watch this course anytime, anywhere. Get started with a free trial today.

Contents