This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 8 in Action this week in the Java 8 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
Similar Threads
Concurrency question
Thread question from
Help in a question about Threads
thread problem
Threads Question