Recently saw some design patterns of the article, I also have some ideas. Is the company is a love travel company, inevitably to buy a lot of train tickets. The process of buying a ticket has been changing. At first, everyone bought their own train tickets and reimbursed them when they returned to the company. Just like this:public class Atfirst {public static void main (string[] args) { emp
For the ticket, seconds to kill this business, I say to the high concurrency of their understanding, here, the personal think that the more feasible several scenarios:
Scenario one: Using Queues to implement
Can be based on such as MEMCACHEQ, such as Message Queuing, the specific implementation of this statement.
For example, there are 100 tickets available for users to Rob, then you can put the 100 tickets
How to use the life calendar to grab tickets
First of all, we will be attached to friends for this year's Spring Festival timetable, to facilitate the friends according to their own time to rob tickets.
After that, we installed the Life Calendar PC version on our PC. After running, we can see the application option at the bottom, choose the category of train ticket in which the life travel is found.
Simulated ticket window, with 4 threads to simulate 4 windows in the ticket, a total of 8 tickets, with thread synchronization to achievepublic class Ticket {public static void Main (string[] args) {for (int i=0;iNew Sellwindow (). Start ();}}}Class Sellwindow extends Thread {private static int ticketall = 100;private static Object obj = new Object ();public void Run () {while (true) {Synchronized (obj) {if (Ticketall > 0) {/* Try {Thread.Sleep (10);}
Description
The public transport administration of Ekaterinburg is anxious about the fact that passengers don't like to pay for passage doing their best to avoid the privilege. all the measures that had been taken (hard currency premiums for all of the chiefs, increase in conductors 'salaries, ction of number of buckets) were in vain. an advisor especially invited from the Ural State University says that personall Y he doesn't buy tickets because he r
HDU 1260: Tickets (DP), hdu1260ticketsdp
Tickets
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission (s): 923 Accepted Submission (s): 467
Problem DescriptionJesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering
POJ2355 -- Railway tickets, poj2355railwayRailway tickets
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:2710
Accepted:962
DescriptionThe railway line "Ekaterinburg-Sverdlovsk" with several stations has been built. this railway line can be represented as a line segment, railway stations being points on it. the railway line starts at the station "Ekaterinburg"
TicketsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 1408 Accepted Submission (s): 687Problem Descriptionjesus, what a great movie! Thousands of people is rushing to the cinema. However, the really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as possible.A good approach, reducing the total time of tickets
TicketsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 1941 Accepted Submission (s): 938Problem Descriptionjesus, what a great movie! Thousands of people is rushing to the cinema. However, the really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as possible.A good approach, reducing the total time of tickets
TicketsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 1935 Accepted Submission (s): 933Problem Descriptionjesus, what a great movie! Thousands of people is rushing to the cinema. However, the really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as possible.A good approach, reducing the total time of tickets
Every holiday train ticket is always difficult to buy, often can not get, a lot of people only in the 12306.cn on the rush to brush the ticket, this 11, 12306 is particularly not to force.
Cheetah Browser has just launched a ticket to rob Special edition, containing ticket assistant third party application expansion, can help netizens to capture the fastest opportunity to buy tickets, but also greatly eliminates the manual brush the ticket when the a
Hello everyone, our company is dedicated to selling movie tickets. Now HTML5 is becoming more and more mature, and the consumption capability of the masses is also increasing. We want to plan an HTML5 ticket sales product, for example, if a movie is sold in HTML5 format, how much does it cost? What factors are required for the benefits of forwarding? Hello everyone, our company is dedicated to selling movie ticket
Halloween tickets.[Halloween party before the start ...]Halloween arrived, Lazyjazz to run a big party (communistParty)!So Lazyjazz invited classmates friends, near relatives total n people, each sent a party ticket. But the day of Halloween, somehow came n+ 1 Individual ( sure is a ghost festival ), and everyone took a ticket, which makes lazyjazz very headache. Fortunately, when the ticket was issued, each coupon printed a verification code. The
Buy Tickets
Time Limit: 4000MS
Memory Limit: 65536KB
64bit IO Format: %i64d %i64u
Submit StatusDescriptionRailway tickets were difficult to buy around the Lunar New year in China, so we must get up early and join a long queue ...The Lunar New year is approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had-to-train-Miany
Buy Tickets
Time Limit: 4000MS
Memory Limit: 65536K
Total Submissions: 15533
Accepted: 7759
DescriptionRailway tickets were difficult to buy around the Lunar New year in China, so we must get up early and join a long queue ...The Lunar New year is approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had-to
Buy Tickets
Time Limit: 4000MS
Memory Limit: 65536K
Total Submissions: 14905
Accepted: 7435
DescriptionRailway tickets were difficult to buy around the Lunar New year in China, so we must get up early and join a long queue ...The Lunar New year is approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had-to
Topic address: Buy tickets
Question:
Simulate buying tickets for a queue. There are n people, each of whom has a pos to be inserted to the back of the nth person, and there is a Val value to update the order of N queues, after the insertion is complete, the Val value is output in the order of teams.
Solution:
Directly simulate insertion. It will not work. It will be TLE. If insertion is in pro
Buy tickets
Time limit:4000 Ms
Memory limit:65536 K
Total submissions:13618
Accepted:6802
Description
Railway Tickets were difficult to buy around the lunar new year in China, so we must get up early and join a long queue...
The Lunar New Year was approaching, but unluckily the little cat still had schedules going here and there. now, he had to travel by train to Mianya
Use the Java runnable interface to simulate parallel programs for multi-window (thread) Sales of the same type of tickets, the same type of runnable
Refer to this blog post (http://blog.csdn.net/liutengteng130/article/details/20036517), where the use of the thread and runnable interface to achieve multi-window ticket simulation problem.
As for the features of the runnable interface implementation method-the multi-thread error-free modification class
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.