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

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…

Contents