synchronized (SaleTicket.class) { while (TicketContainer.tickets > 0) { TicketContainer.buy(); } }