usc-csci201-fall2013 / restaurant

CSCI 201 - Fall 2013 - Restaurant
2 stars 12 forks source link

Synchronization Issue #98

Open waynchi opened 10 years ago

waynchi commented 10 years ago

Hi, I implemented the synchronization steps and all of that worked great for the most part. However, there was a portion of my program that was unable to run because of the synchronization blocks. It would just halt my program completely. How do we get around this? (I did use synch blocks and created synched ArrayLists, it just completely halts my program.)

lshiffer commented 10 years ago

I had the same issue. Synched everything and program wouldn't even load the gui, just output three lines from the Market. Removing the sync around the iteration in the Market's scheduler fixed the issue but wondering how to have that sync without the hold up.

BachDinh1994 commented 10 years ago

Does anyone know how much extra credit is given for incorporating Astar into this project?

EliteSoba commented 10 years ago

Well I can't say for certain without playing around with your code to pinpoint the exact issue, but in a broader sense this problem will happen when you have a synchronized block of code that waits on another synchronized block of code to finish and both blocks of code are monitoring the same data.

And Bach, that question is completely unrelated to the issue at hand, but I don't quite know either.

waynchi commented 10 years ago

Yea, that's what I kind of figured. I don't really know a proper fix though...

EliteSoba commented 10 years ago

You could just start removing synchronized blocks and see when you stop getting errors, and then check to see why that synchronized block would cause your program to die.

lshiffer commented 10 years ago

Can you locate where the issue is?

I fixed my problem by changing the synchronized block to a try/catch.

waynchi commented 10 years ago

Yea, I'm just trying removing and changing things, but I don't really get WHY it's just dying

diegovb commented 10 years ago

This happens when there are "synchronization loops" where thread A is waiting to access data locked by thread B, but thread B is waiting to access data locked by thread A. What you can do is open your program in debug mode, and when it get frozen, pause the program and look at the stacks of each of your threads. It will show what threads are waiting for data, and what threads are holding said data. That can help you figure it out.