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 Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads" Watch "Threads" New topic


Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Consider this code..

the out put is

Am not able to understand the flow

SCJP 1.5
mandlar suurla
Ranch Hand

Joined: Jun 11, 2008
Posts: 67

What dont you understand there ? Why you got Exception is that your throwing it.

Heres my code

[ July 20, 2008: Message edited by: mandlar suurla ]
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
I think he wants to know why End is printing first. If I am correct, I would suggest you to read join

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24166

Originally posted by mandlar suurla:

Heres my code

Don't know what this adds to the discussion. You would never call "run()" on a Thread, as it's only by calling "start()" that you invoke the special behavior of a thread. And of course the "Runnable" route is preferable to subclassing Thread. satishkumar's advice is good.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Threads
Similar Threads
Can we only start() a thread?
main method problem
Question about Threads
a tip on threads: (follow up)