My code (a thread, actually "implements runnable") spawns threads (runnables) to handle listening for incomming messages and stores them in an ArrayList (I could not think of a better way, please propose a better method if possible). This is done as such:
public static ArrayList chList;
public void run() { chList = new ArrayList(); chList.add(new serverListen());
This should allow me, when I want to close my main thread (runnable), to close all my listener threads (serverListen runnable) using the ArrayList (chList). -- Quick question, I can do a .STOP on my listener threads (serverListen runnable) from this main thread right? (I create a public void stop(){ thread.stop;} function in my serverListen threads, I can do this right? if not how am I supposed to kill a thread from this scope? ---
So my problem is unlike a normal Array the ArrayList doesn't seem to allow me to go through each index and do a serverListen.stop()
So my goal is to do something like for (int i = 0; i < chList.size; i++) { chList.stop() } Of course this is not working for many reasons (doesn't like "chList", and "chList.stop" doesn't seem to be recognized either). Is there anyway to do this? A better way? Any help would be GREATLY appreciated, thanks.