Samir Aguiar

Greenhorn
+ Follow
since Mar 19, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Samir Aguiar

Hello there,

I have an assignment where I need to simulate a parking lot.
The cars will stay in a waiting line while all the parking places are being used.
After one of them is freed, one car from the waiting line can park.
There are three kind of users. F users take priority over A users, while D users take priority over both F and A users.

So I have three threads, D, F and A.
I also have three more classes, Car, ParkingLot and Main.

ParkingLot is shared between the three threads, and each thread has a Car object.
ParkingLot has methods to take a parking place, release a parking place, take a place in the waiting line, release a place in the waiting line and some others.

The Main class will create the threads and start them. The threads will then try to park, and when the parking lot is full they'll be waiting.

The waiting line and the parking places are arrays of Car objects.

Here's the method to park, which is called by the three threads:


My problem is: how do I set the priority for the threads? I tried to use setPriority(), but to no avail.

Any ideas?
I'm also not sure if my implementation is right, so I appreciate any advice on this.

Best regards,
Samir