I am quite new to Multi-Thread systems and have a question regarding a suitable data structure for objects.
I have an object image which has several attributes, two of them are a byte array data storing the image data and an int variable status storing the status.
I have some form of a conveyor belt architecture, meaning having a camera-thread storing the data into the image attribute, followed by a converter-thread, followed by a processing-thread. So one thread has to work on the output of the predecessor thread.
To avoid synchronizing and increasing the efficiency, my idea is to have a LinkedList<Image>
storing image objects. The webcam-thread creates the first image object, assigns the status=1 (meaning data writing in progress) and assigns status=2 if it finishes and heads over to the next image. The following converter-thread only reads the status attribute, if it is 1 it sleeps or awaits (can be signaled by the webcam-thread), if it is 2, it assigns status 3 and starts its work. When it is finished it sets the status=4 and continues with the next image object. The next Thread again reads the status, and will sleep if the status < 4 and so on.
Finally my question is, whether there will be problems caused by the possible simultaneous access by two different threads, while assuring that only one is a write operation and the other (read) access is even conducted on a different attribute/variable (of the same object).