Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / September 2005

Tip: Looking for answers? Try searching our database.

How can 'java' launch a multithreaded program?

Thread view: 
Paul J. Lucas - 12 Sep 2005 17:28 GMT
    I'm looking at the source code for the 'java' command-line tool
    written in C.  Near the bottom of main(), it calls the static
    main() method of the main Java class via CallStaticVoidMethod().
    It then detaches the current thread and destroys the JVM via
    DestroyJavaVM().

    The thing I don't understand is what if the Java main class's
    main() spawns a thread, runs in that thread, whereas the
    original thread returns from main() and dies.  The call to
    CallStaticVoidMethod() will then return and the C code will
    continue, and then call DestroyJavaVM() effectively killing the
    JVM out from under the still-running Java program.

    This is what can happen in a Java Swing application where its
    main() creates the AWT event thread and the application runs in
    it, yet the original thread returns from main().

    So how does this work?  How is the call to DestroyJavaVM()
    deferred?

    - Paul
Boudewijn Dijkstra - 13 Sep 2005 17:37 GMT
> I'm looking at the source code for the 'java' command-line tool
> written in C.  Near the bottom of main(), it calls the static
[quoted text clipped - 15 lines]
> So how does this work?  How is the call to DestroyJavaVM()
> deferred?

Have you looked at the source of DestroyJavaVM()?  My guess it would wait for
all threads to die, and *then* destroy the VM.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.