File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes is the thread running? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark " is the thread running?" Watch " is the thread running?" New topic
Author is the thread running?

Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
Hi... i have a very basic question about threading. I know that to use threading in our class we need to either implement Runnable interface or extend the Thread class to our class and then call start() to bring the thread into its life cycle. A thread can be brought into its life cycle only after calling is one and only one method i.e. start().

My question is if i call run() directly then what it is doing exactly ? What i think is that it is just calling the run() and working as a normal class method only. And it has not behaving like a thread i.e. not bringing the thread into its life cycle.

Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

That's right. It'll just execute the run() method in the current thread, and no new threads will be created.
Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
Thanks buddy ...
I agree. Here's the link:
subject: is the thread running?
It's not a secret anymore!