Giter Site home page Giter Site logo

thread_story_busywaits's Introduction

Thread Story: Visitors in the theater

The story

Visitors want to come and watch a movie at the museum. When the theather is not in session and the theater is empty, visitors rush in and grab a seat, until all seats are filled, and any visitors still in the theather exit politely(yield) and leave the theather. Once everything settles, the movie watchers get to see the movie, and when it ends, form groups of fixed sizes (except for one group if possibly uneven). Once grouped up, the speaker will distribute tickets to each group, and then wait until the end of the NEXT movie session. Once everyone has their tickets, visitors can leave (anytime) AS LONG as all visitors with smaller ids have left already, and once done, they head home. Once the theater clears out, visitors who haven't watched the movie may rush in again.

By default, only 4 movies shown in the day, and the museum closes at the end of the 4th movie. If visitors haven't gotten the chance to watch, they leave as the museum and head home.

To run:

javac Main.java && java Main <integer value for number of visitors>

thread_story_busywaits's People

Contributors

pr0grammar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.