This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where to start threads

 
Alice B Palmer
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've been trying to use threads, but I keep having problems. I found this bit of code and was wondering if I should be starting my threads within the public void run() int he main(String[] args) bit (underneath the createAndShowGUI).

/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);

//Create and set up the window.
frame = new LoseMe();
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

//Display the window.
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}

Or does it really matter where threads are started?
 
Alice B Palmer
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I now understand how the code button works. Let me try it again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic