• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why main thread should complete before other threads

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Basic Question why main thread should be completed before the
all the thread in java.
Regards,
Sangeetha
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's just a matter of program design. I have a little program that spins off a number of threads to do some work. I read the starting point for each thread from a file and rewrite the file to record how much got done. I stop all those worker threads before the main thread rewrites the file and exits the program.
There are programs that can let the main thread end while other threads go on. Have you done any Swing programming? You might write a little main() routine that opens a frame. Opening the frame gets the Swing thread going, and the Swing thread goes until you shut down the program, even though the main ended almost immediately.
Do those examples help?
 
reply
    Bookmark Topic Watch Topic
  • New Topic