R
Rakesh
I am working on a tree traversal algorithm ( reduced form of the main
problem ) - such that we need to figure out the different paths from
the root of the tree to the leaves of the same.
Assuming a BFS algorithm to begin with - I was thinking along the
following lines..
1) Initialize a global blockingQueue..
2) For each child
spawn a new thread for each child.
add child to the current path ..
repeat the algorithm until leaf is reached.
3) If node is a leaf - consolidate the list of nodes visited
(accumulated throughout the thread).
Put it in the blockingQueue to indicate the result.
For each and every step - whenever I need to spawn a new thread , I
wanted to do it under the control of an executor such that -
executor.executor(runnable).
My Q is - (as per the algo above) - clearly multiple threads would be
using the same executor to launch new sub threads. Is the executor
thread-safe with multiple threads calling execute method (with
different instances of Runnable ) of the same Executor reference.
problem ) - such that we need to figure out the different paths from
the root of the tree to the leaves of the same.
Assuming a BFS algorithm to begin with - I was thinking along the
following lines..
1) Initialize a global blockingQueue..
2) For each child
spawn a new thread for each child.
add child to the current path ..
repeat the algorithm until leaf is reached.
3) If node is a leaf - consolidate the list of nodes visited
(accumulated throughout the thread).
Put it in the blockingQueue to indicate the result.
For each and every step - whenever I need to spawn a new thread , I
wanted to do it under the control of an executor such that -
executor.executor(runnable).
My Q is - (as per the algo above) - clearly multiple threads would be
using the same executor to launch new sub threads. Is the executor
thread-safe with multiple threads calling execute method (with
different instances of Runnable ) of the same Executor reference.