From the course: Java Threads
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Starting a thread - Java Tutorial
From the course: Java Threads
Starting a thread
- [Instructor] The thread class has a method named start that takes no arguments. When you call this method on a thread object, it causes that thread to begin execution. In other words, the running behavior of the thread is triggered by the JVM by internally calling the run method of the thread. A thread can be run by calling its run method directly. But that's not how it should be done, because, then, it'll not behave as a thread. I'm back in the main class where I created a thread object from my first thread class. I'm calling the start method on the thread object. thread1., there's the run method here, but I'm not going to call that. I'm calling the start method. When I run the program, it prints out one to five as expected, but you do not see anything special here yet. After all, we are talking about multi-threading. So I'll go ahead and create three additional threads from my first thread class. Instead of creating…
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.
Contents
-
-
-
-
Thread class and Runnable interface2m 17s
-
(Locked)
Creating a thread: Extending the Thread class4m 4s
-
(Locked)
Creating a thread: Implementing the Runnable interface3m 31s
-
(Locked)
Starting a thread7m
-
(Locked)
Extend a thread or implement a Runnable?2m 27s
-
(Locked)
Challenge: Webinar polling system3m 25s
-
(Locked)
Solution: Webinar polling system3m 33s
-
-
-