I am having some problems with threads. The easiest way to
illustrate my troubles is with some examples. So here goes:
Say I want to create a class which is a sub-class of thread
eg.
public class ThreadClass extends Thread
{
public void run()
{/*Stick stuff here*/}
}
But say I also wanted to be able to modify attributes of that
Thread while it is running
eg.
public class ThreadClass extends Thread
{
boolean attr; //an attribute that will determine whether
//the thread is to continue running
public void run()
{
attr = true;
while( attr )
{
/* STICK STUFF HERE */
}
}
public void discontinue()
{
attr = false;
}
}
My Question is, how would I use such a class so that I would
be aloud to call the discontinue method from an external class
(or a similar method that would modify some kind of attribute
of the Thread class)
Any explanations would be deeply appreciated.