Hi,
I have to make an application that starts several threats and they all have to "listen" for another event. I have a class "Test.class", in this class I have made a vector and for each element of the vector I have to start a thread.
class Test{
public static void main(String args[])
{
Vector v = new Vector();
Enumeration e = v.elements();
v.addElement(new Mon("mon1","..."
);
v.addElement(new Mon("mon2","..."
);
while(e.hasMoreElements())
((Mon)(e.nextElement())).startThreads();
}
}
The class Mon contains the method startThreads()
class Mon{
private String MonName;
private String MonInfo;
public void startThreads()
{
...
}
public void run()
{
}
The problem is I don't know how to call the method run for each element of the vector from the method startThreads..
I know I have to call the runmethod with a "start" function but I tried mon.start() but it didn't work..
Help will be appreciated
Outliner
I have to make an application that starts several threats and they all have to "listen" for another event. I have a class "Test.class", in this class I have made a vector and for each element of the vector I have to start a thread.
class Test{
public static void main(String args[])
{
Vector v = new Vector();
Enumeration e = v.elements();
v.addElement(new Mon("mon1","..."
v.addElement(new Mon("mon2","..."
while(e.hasMoreElements())
((Mon)(e.nextElement())).startThreads();
}
}
The class Mon contains the method startThreads()
class Mon{
private String MonName;
private String MonInfo;
public void startThreads()
{
...
}
public void run()
{
}
The problem is I don't know how to call the method run for each element of the vector from the method startThreads..
I know I have to call the runmethod with a "start" function but I tried mon.start() but it didn't work..
Help will be appreciated
Outliner