Hi guys.
I've got two classes.
The first, is the primary (with void main, etc), it calls the secondary which is threaded to do something, waits for an available thread, then launches another one.
at any time there should be 10 threads running. the main function doesn't care about anything about the threaded class except whether or not the max_threads limit was reached. so, the main class will launch 10 threads, and just wait until 1 dies and launch another one, always keeping 10 threads running, but not caring about the result of the thread.
currently, when a thread finishes executing, it updates the thread count (active_threads int) on the main class. (ex: when it starts in run() it increments it and when it finishes in run() it decrements it) so that the main module knows how many threads are running.
here is the change need to make, currently i reference directly to the parent module like WS.active_threads--;
but what if I wanted to make the threaded module usable in other parent modules that may not be called WS but something else.
I tried with super.active_threads--; and then created a function on the parent thread to do it too super.dec_threads(); but it doesn't work (java error). Assuming that there will always be a active_threads integer on the parent thread, but the parent thread's name is not always known, is there any way to increment it?
Additionally, is there a way to perform a call on like a postback function, say i want my thread to execute a function on the parent thread when it's done?
Thanks!
Luc
I've got two classes.
The first, is the primary (with void main, etc), it calls the secondary which is threaded to do something, waits for an available thread, then launches another one.
at any time there should be 10 threads running. the main function doesn't care about anything about the threaded class except whether or not the max_threads limit was reached. so, the main class will launch 10 threads, and just wait until 1 dies and launch another one, always keeping 10 threads running, but not caring about the result of the thread.
currently, when a thread finishes executing, it updates the thread count (active_threads int) on the main class. (ex: when it starts in run() it increments it and when it finishes in run() it decrements it) so that the main module knows how many threads are running.
here is the change need to make, currently i reference directly to the parent module like WS.active_threads--;
but what if I wanted to make the threaded module usable in other parent modules that may not be called WS but something else.
I tried with super.active_threads--; and then created a function on the parent thread to do it too super.dec_threads(); but it doesn't work (java error). Assuming that there will always be a active_threads integer on the parent thread, but the parent thread's name is not always known, is there any way to increment it?
Additionally, is there a way to perform a call on like a postback function, say i want my thread to execute a function on the parent thread when it's done?
Thanks!
Luc