C
Christian Schmidt
Hello,
I'm using threads for the first time and got some trouble with finishing
a thread.
An example:
In a constructor of class1 I create and start a new threat (class2).
Whenn calling the shutdown func. of class1 I want to finish the threat
(class2). The run method of class2 looks like:
private volatile boolean doSomething = true:
public void run {
while (doSomething) {
...
}
System.out.writeln("End.");
}
And there is a stopIt method I call from class1 in the shutdown func:
public stopIt()
{
...
this.doSomething = false;
}
But the "End." will never dumped...
What is the right way... ??
thanks in advance for help
Chriss
I'm using threads for the first time and got some trouble with finishing
a thread.
An example:
In a constructor of class1 I create and start a new threat (class2).
Whenn calling the shutdown func. of class1 I want to finish the threat
(class2). The run method of class2 looks like:
private volatile boolean doSomething = true:
public void run {
while (doSomething) {
...
}
System.out.writeln("End.");
}
And there is a stopIt method I call from class1 in the shutdown func:
public stopIt()
{
...
this.doSomething = false;
}
But the "End." will never dumped...
What is the right way... ??
thanks in advance for help
Chriss