File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic


soujanya Bugatha

Joined: May 29, 2012
Posts: 10
The output of this program is "BeginRunEnd" can anyone explain this to me?

public class Cruiser implements Runnable {
public static void main(String[] args) throws InterruptedException {
Thread a = new Thread(new Cruiser());


public void run() {
Rahul mir
Ranch Hand

Joined: Oct 31, 2012
Posts: 38

Start() starts the thread by calling its run() method.
Here, after start method call print statement will Print "Begin", after that compiler go for run() method, Thread is still not started, so a.join() will execute after run() method and the final result will be "BeginRunEnd"
I agree. Here's the link:
subject: Threads
It's not a secret anymore!