I have a button \"addCashier\" which is creating a thread called \"Cashier\" now this thread is just simply generating orders every 4 seconds, a while(true) loop in the run(
You can keep a reference of the Thread object somewhere so that u can call threadObj.logOff()
If you are not willing to do that then while creating a thred u can assign a unique name to the thread.
public void run ()
{
this.setName(strCashireID);
......
}
At runtime, u can get the thread by:
Thread getThread(String strCashireID) {
ThreadGroup threadGroup = Thread.currentThread( ).getThreadGroup( );
Threads[] threads = new Thread[ threadGroup.activeCount() ];
threadGroup.enumerate(threads);
for (int nIndex=0; nIndex
I'll still suggest that u store the thread objects in a hash map instead of enumerating them at runtime.