Hi everyone
I have a
thread issue in my code that should not be happening - but is. So I'm trying to make some work around. I will try to explain my problems with simple code as I can - because the code that I'm experiencing the issue is big and complicated so in short the code:
So my problem begins when two thread are trying to execute-read-write changes on the same jobObject at the same time that makes mess in my application
What I need is a way that when a thread is entering "if(job.getStatus.equals("redye")){" with e.g. job object with id=1111 no other thread can enter this code for the same jobObject-1111 until the first thread is finished - leaves the if statement
I also have problems synchronizing it because the "execute" method is call with different instance of ExecuteJob
I can use ExecuteJob.class for synchronization but I will lose the point and benefits of multithreading
I'm wondering if there is something like this that can be implemented for my issue:
or maybe