Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn Java threading in 10 minutes! 🧵
Play lesson

Java tutorial for beginners ☕ - Learn Java threading in 10 minutes! 🧵

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse import java.util.Scanner; public class Main { public static void main(String[] args) { // Threading = Allows a program to run multiple tasks simultaneously // Helps improve performance with time-consuming operations // (File I/O, network communications, or any background tasks) // How to create a Thread // Option 1. Extend the Thread class (simpler) // Option 2. Implement the Runnable interface (better) Scanner scanner = new Scanner(System.in); MyRunnable myRunnable = new MyRunnable(); Thread thread = new Thread(myRunnable); thread.setDaemon(true); // This thread will end when Main thread finishes thread.start(); System.out.println("You have 10 seconds to enter your name"); System.out.print("Enter your name: "); String name = scanner.nextLine(); System.out.println("Hello " + name); scanner.close(); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere