Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-24-2008, 10:05 PM
Member
 
Join Date: Jan 2008
Posts: 7
frejon26 is on a distinguished road
main thread question?
are there any problems that arise from letting the main thread finish execution before sibling threads finish. I know the thread.join() method prevents this when you have a reference to the thread object running.

on my computer it does not seem to casue any visible problems.

-thanks

Last edited by frejon26 : 01-24-2008 at 10:18 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-24-2008, 11:13 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 251
roots is on a distinguished road
Java Doc Thread Class and Thread.setDaemon() and this link might help you.

I played with this code
Code:
import java.io.FileNotFoundException; import java.io.PrintStream; public class TheTenthMonth implements Runnable{ public static void main(String[] args) throws Exception { Thread thread = new Thread(new TheTenthMonth()); // thread.setDaemon(true); thread.start(); System.out.println("I am already pregnant"); // System.exit(1); // This makes difference } @Override public void run() { try { Thread.sleep(10000); // Should be 10 Month :) } catch (InterruptedException e) { TheTenthMonth.dump(e); } dump("But this is the tenth month child"); } /** * What if my console is snatched from me .. Does not happen but to make sure.. */ public static void dump(Object o){ System.out.println(o); PrintStream out; try { out = new PrintStream(Math.random()+".txt"); out.print(o); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
data from the main/GUI thread to another runnin thread... cornercuttin Threads and Synchronization 2 04-23-2008 11:30 PM
main() thread in Java JavaForums Java Blogs 0 12-17-2007 01:21 PM
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main barney New To Java 1 08-07-2007 08:10 AM
Exception in thread "main" java.net.ConnectException: Connection timed out osval Advanced Java 1 07-27-2007 11:59 PM
ArrayList: Exception in thread "main" java.lang.NullPointerException susan New To Java 1 07-16-2007 07:32 AM


All times are GMT +3. The time now is 11:04 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org