Hello, i recently got some homeworks to do about fixing a producer/consumer class, and I am doing all my classnotes tell me to but it's not working (or at leash has it should). The problem consist in 2 actors, one produce food othe consume, you can't consume food if arraylist is empty and you can't produce if arraylist have more than 3 dishes. Any thoughts why the method server start before produece?
#Monitors problem
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
I'll look at this later, but fair warning
multi-threading is hard
locks are the harder part of that
and wait/notify are very hard
so I might not be able to tell whats wrong at a glance
if you can share this in a way i can run it on my machine (or someone else who wants to take the question) that would be helpful
if this wasn't a school assignment i would be telling you to not use synchronized or wait/notify
i would be showing you things in java.util.concurrent that already did most of the hard work
oh sure i can send u the code in .tar or here as u wish
github would be better, but thats fine for me
ok
ping me later in the day
i have work to do now for my normal job
or if anyone else is reading, feel free to pick it up
https://github.com/CarlosSP99/MonitorsIssue here you go
alright I have lot of time to complete the task so np
what is your actual assignment?
is it "use synchronized and wait/notifyAll to make a producer/consumer"
or would we be able to use built-in queues
The main problem here is that i need to fix anykind of race problems
by using monitors
It is a restaurant app, not sure if you need more info if you do i can transalate the problem
Race conditions sorry
@azure wren
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure 👍
@lucid crow hey man I ve been asking in other servers and testing some stuff and I feel like i was the solution and I was obsesing to fix something that is not broken, this is the log i ve got without syncronized in the method