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.

Learning Java Threads

How to create a thread

From the course: Learning Java Threads

Start my 1-month free trial
  • Course details

    Threads are independent paths of code execution that run concurrently in a Java program. Your app can use threads to multitask: perform time-intensive tasks and run them in the background. This allows the application to remain responsive to users. While multithreaded programming in Java has a reputation for difficulty, most developers can untangle it with smart, designed-for-concurrency constructs that are standard with the Java platform. Join staff instructor Peggy Fisher in this course as she helps you untangle Java threads. Watch and learn how to create, manage, sync, and lock threads, and review concurrency utilities that will make multithreaded programming a lot easier.

    Instructor

    • Click here to view Peggy Fisher’s instructor page

      Peggy Fisher

      Content Strategist, Software Development Languages at Linkedin Learning Solutions with Lynda.com content

      • Peggy Fisher is a programmer and content manager at LinkedIn Learning.

        Peggy's main focus is application programming in Java, Arduino, and C++. She has also worked on courses in COBOL and discrete ,athematics. Previously she was a faculty member at Penn State University's College of Information Sciences and Technology. She started out as a programmer working for a large insurance company, but after 18 years she left her job as a director of information technology to pursue her true passion teaching. She earned a master's degree in math education, and went on to teach high school math and computer science in Pennsylvania. In 2012, Peggy accepted a position as an instructional designer at Penn State, and shortly thereafter began teaching Intro to Application Programming with Java. She is a strong supporter of women in STEM. As one of the few female programming teachers, she serves as a mentor to incoming female freshmen who are considering a career in programming. She was also the K–12 outreach coordinator for the college, where she scheduled, ran, and taught summer camps for middle school and high school students. In a PBS NewsHour interview, she expressed that all students should take at least one programming class either in high school or college. Peggy enjoys constantly learning and finding new and exciting ways to bring technology to life in and outside of the classroom, such as using Arduino microcontrollers or Lego Mindstorms, to help make learning hands-on and fun.

    Skills covered in this course

  • Welcome

    - [Teacher] Now that we have a better understanding about what a thread is in Java, let's take a look at how to create a thread. There are basically two ways to create a thread in Java. The first way is to declare a new class that is a subclass of Thread class. Remember, you would do this using class, name, extends, Thread, using a capital T for the Thread class. This subclass must override the run () method. Then an instance of this subclass which is a thread can be allocated and started. The other way to create a thread is to implement the Runnable interface which can be done by creating a new class that implements Runnable or you can create a Runnable object that is passed to a Thread constructor. All of these approaches still require that we override the run () method with a code that should be executed by that particular thread. For this series I will be using the second approach for most of my examples. As I alluded to, the Thread class provides several constructors for…

  • 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