// structure is like this, but not exact formation.
class queue
{
volatile List<pieceOfWork> worksWaiting;
}
List<queue> qs; // pieceOfWork has only some primitive arrays and strings.
Is it safe to read/write(not destroy, not create) elements of "Qs" from N threads at the same time?
"WorksWaiting" is meant to synchronize between controller thread(1 or 2) and a controlled thread (N) while N controlleds reading/writing to Queues concurrently.
Deletion/creation of queue will be made of controller threads.
Thanks you.
th read th write
(cpu sse) (gpu opencl executor)
^ ^
| |
W W W W W W ....w<--- controller thread adding new works to queue and
deleting finished ones.
also splits a work item if
it is not finished in short time.
WorksWaitingnorQshave been initialized, so it's unclear if a thread-safe list implementation is used there. Apart from that: Variable names should be lower case in java. AndQueueueshould probably beQueueinstead.Listis just an interface, not an implementation. What concrete implementation are you assigning toworksWaitingandqs?qsisnullas you've not assigned anything to it yet. Somewhere in your code you must create a new list instance and assign it toqsviaqs = new .... So what kind of object do you create there?