aspose file tools*
The moose likes Beginning Java and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Amudha
Greenhorn

Joined: Jun 09, 2000
Posts: 1
Should the main thread be the last to be executed as few books say.What would happen if my main thread was not the last thread that was executed
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Executed or started?
Think of Java as a multi-threaded environment. If thread A starts thread B and then thread A ends, thread B may still be executing. No problem.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Originally posted by Amudha:
Should the main thread be the last to be executed as few books say.What would happen if my main thread was not the last thread that was executed

it totaly depends on operating system if u r woorking in Windows Environment ,there is no problem but if ur working other os than it may problem becoz it terminates the child thread as soon as main thread exits and that may lead to file coorupted,data corruption on which ur child thread is operating on.So it is always advisable to use Join() .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threads
 
Similar Threads
main thread
Predict the output and why is it what it is ? - Thread related Q
tthread doubt
Doubt with a thread question about "synchronized(sa)"
Where would the return from main go to?