I am learning about multithreading. It's my first task. I wrote this code and i can't move on. Task:

Ski lift with capacity equal N. 
Clients have a weight (random Ki value) and They are threads that execute in
loop:

1. downhill(sleep(big random value)
2. Try to get into the lift (if the total weight of customers is
Less than or equal to N).
3. If it failed - they are waiting (sleep(small random value)
and re-execute the previous point.
4. if it was successful - they go up.

```

public class Client extends Thread
 {
    private SkiLift lift;
    private int weight;
```

```
public Client(SkiLift l, int w)
{
    this.lift = l;
    this.weight=w;
}

public int getWeight()
{
    return weight;
}

public void run()
{
    for (int i =0; i<10; i++)
    {
        lift.downhill(this);
        lift.goIn(this);
        this.setPriority(MAX_PRIORITY);
        lift.drive(this);
        lift.goOut(this);
        this.setPriority(5);
    }
}

```

}
public class SkiLift 
{
 private static int actualLoad=0;
 private static final int CAPACITY=300; 

`synchronized public void goIn(Client client)
{
 try
 {
 System.out.println("Client " + client.getId() + " try to get into the lift");
 while (actualLoad>CAPACITY)
 {
 System.out.println("The Lift is full!");
 client.sleep((long) (Math.random()*1000));
 wait();
 }
 }
 catch (InterruptedException e) {}

 System.out.println("Client " + client.getId() + "get into the lift " );

 actualLoad+=client.getWeight();
 System.out.println("actual load = " + actualLoad);

}

synchronized public void goOut (Client client)
{
 System.out.println("Client "+ client.getId() + " leave the lift ");
 actualLoad-=client.getWeight();
 System.out.println("Actual load = " + actualLoad);
 notifyAll();
}

public void downhill(Client client)
{
 System.out.println("Client nr: " + client.getId()+ " downhill ");
 try
 { 
 client.sleep((long) (Math.random()*10000));
 }
 catch (InterruptedException e){}

}

public void drive(Client client)
{
 try
 {
 client.sleep(9000);
 }
 catch (InterruptedException e){e.printStackTrace();}
}`
}

I have three problems and i can't solve them: 

1. The first who will enter must to be the first who has attempted to enter. (Just like in a queue)
2. The client who first came on the lift must also be the first to go down.
3. What is the moniotor in my program?

Thanks in advance :)