Scope of Threads
Does anyone know. I want to have users be able to enter commands into a text field, and then have the text field action listener create a new thread to handle the command (because some commands are really long). My question is, after I start the newly created thread, and then return from the actionPerformed method, the newly created thread will no longer have any references pointing to it because it will have gone out of scope, so does that mean that the thread might be garbage collected while it is still running? Here is how My action listener works. Thank you.
inputField.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e)
{
JTextField field = (JTextField)e.getSource();//safe cast
String command = field.getText();
field.setText("");
UserCommandThread userCommandThread =new UserCommandThread(infoSocket, command, console);
userCommandThread.start();
}
});

