public class BUYER {public static void Main (string[] args) {Testthread a=new Testthread ();Testthread b=new Testthread ();A.setname ("A");B.setname ("B");A.start ();B.start ();}}Class Testthread extends Thread{static int rest=10;//number of votes leftint buy_1=7;//buy Ticket numberpublic void Run () {int a=rest;if (a>buy_1) {A=a-buy_1;Rest=a; ① Why the statement is placed here can never appear at the same time the success of the purchase of the caseSystem.out.println (Thread.CurrentThread (). G
buys the journey (from the bus station to the destination station) and the return (from the destination station to the bus stop).
4. Where to buy tickets?
Passengers can go to the Railway ticketing window (including the railway station ticket window, automatic ticketing machine and railway ticket sales point) to buy train tickets, can also log on to the 12306.cn website after the registration of ticket
Package Map;public class Test {public static void Main (String args[]) {/*new Testthread (). Start (); *//*testthread T =new testthread ();New Thread (t). Start (); */* Since runnable has only the Run method, you must call the thread's Start method *//*for (int i=0;i{System.out.println ("Main thread is running" +i);} *//* Started 4 threads, each using their own resources, did not achieve the purpose of resource sharing *//*new Testthread (). Start ();New Testthread (). Start ();New Testthread ()
thread object to represent different ticketing pointsThread T1 =NewThread (MT); Thread T2=NewThread (MT); Thread T3=NewThread (MT); T1.start (); T2.start (); T3.start (); }}The output is different every time you run it, and here's a result to choose from.Get a ticket, now votes: ticket = 3Get a ticket, now votes: ticket = 2Get a ticket, now votes: ticket = 3Get a ticket, now votes: ticket = 1Get a ticket, now votes: ticket = 1Get a t
This is a mock-up of station ticketing, where multiple ticketing staff sell a high-speed rail (G250) at the same time. ), the basic guarantee for ticket sales is 2 points:1. Tickets cannot be sold more than the predetermined limit.2. Tickets with the same seat cannot be sold.Beginner Java, there are inappropriate places everyone crossing please advise ~The code is as follows: PackageThreadjava; Public class
Python implements multithreading primarily through the threading package in the standard library.In today's network era, every server receives a large number of requests. The server can handle these requests in a multi-threaded manner to improve the read and write efficiency of the network ports.Python is a Web server's background working language (such as Douban), so multithreading is naturally supported by the Python language.Multi-threaded ticketing
I. Java Multithreading Mode 2: Implementing the Runnable Interface Benefit: A. Can avoid limitations due to Java single inheritance.B. Suitable for multiple same program code to deal with the same resource situation, the thread and program code, data effectively separated, better reflect the object-oriented thinking. (e.g. multi-window ticketing)1. Steps:A. Custom class implementation interfacesB. Overriding the Run () methodC. Creating the class ins
Thread safety issues:
The root cause of thread safety:
1. There are two or two thread objects that share the same resource;
2. Multi-threaded Operation shared resource code has multiple statements.
Solution for thread safety problems (2):
Mode one: Synchronizing code blocks
Format: Synchronize (lock object) {
Code that needs to be synchronized
}
The things to keep in mind when synchronizing code blocks:
1. The lock object can be an arbitrary object;
2. A thread in the synchronized code block sl
interested in this)
Video Data base
Book Database
No forum system with many integration issues
A ticketing system similar to the WordPress TRAC
Design albums or collections
You can also think of more content models than I enumerate. And I also want to learn more about the forum and the ticketing system in the future. These two systems I have achieved and want to get some feedback.
Crea
the latest version 12306 grab ticket code please go to http://www.zuidaima.com Download:2014 new 12306 Rob votes code
GoHome The latest edition was born ... Support many people to book tickets and designated train and other functions ... More convenient.
Java Program GoHome automatic ticket grab success. Very good ~ ~ ~ Not much to say, direct screenshots on the tutorial instructions.
Everyone is grabbing tickets, but who let us be programmers? Programmers have to grab tickets in their own way.
2015 Spring Festival train ticket grab ticket Raiders
More tickets to the Software View: 2015 Spring Festival Rush ticket Topic
2015 Spring Festival travel time: The 2015 Chinese New Year is from February 19, so, the 2014-year Spring Festival travel time from February 4, to the end of March 15, a total of 40 days. The Lunar New Year Spring Festival is the 2014 month of 16-2015 year 25. Since November 28, 2014, the Railway department will be the internet, telephone boo
Background: Recently, the company is doing a scenic spot management system based on Springboot, the project will have all the functions to do a project, now the customer needs to put the front desk ticketing and background management deployed to two domain names, I am responsible for splitting the project, decided to use idea to create two project, The service and entity, DAO are divided into a common module, two projects are referenced, toss after th
There are two ways to implement multithreading in Java. The first is the direct inheritance of the thread class, and the second is to implement Runnable interface. So what is the difference between the two ways of implementing multithreading?
The first way: Create a thread using the Runnable interface
Second way: Directly inherit the thread class to create an object
Creating a thread using the Runnable interface
1. Can separate the CPU, code and data to form a clear model
2. The class wh
Tags: Serialize statement read idea good ticket cannot status ZabOracle provides three isolation levels: 1. Read commit, in short, only read the data submitted before the statement starts executing 2. Serial, this good understanding, is the transaction serial operation, avoids the classic three scenes-dirty reads, non-repeatable reads, the Phantom reads. 3. Read-only, read-only mode that Oracle has implemented. -- These are easy to understand, the crux of the problem is to solve some practical p
Geode is a real-time, high-consistencyDistributedData management platform, the typical case is the China Railway 12306 ticketing system uses Geode to manage 10 cluster nodes, manage 2T of hotspot data in memory and 10 highly available elastic-scale backup nodes. Geode manages objects and behaviors across multiple processes through memory pool CPU network resources and optional local disks, which use dynamic replication and data partitioning technology
How to deal with various terminalsDingchang Poetry
I don't know if the subway ticketing terminal is swollen. cmd said hi ~ The Emperor's airport navigation terminal is a model in the industry, but it does not seem to have been pushed ~ Magu subway ticketing terminal has always been well-behaved. Can it be left blank? The 6C community payment terminal has a strike. Double-click the three-button to stop it ?.
This article was reproduced from: Http://www.linuxidc.com/Linux/2013-12/93690.htm#0-tsina-1-14812-397232819ff9a47a7b7e80a40613cfe1 There are two ways to implement multithreading in Java. The first is the direct inheritance of the thread class, and the second is to implement Runnable interface. So what is the difference between the two ways of implementing multithreading?To answer this question, we can write a piece of code to analyze. We use the code to simulate the railway
Python mainly uses the standard library threading package to implement multithreading.Today, the Internet age, all servers you will receive a large number of requests.The server will take advantage of multithreading to handle these requests in order to improve the read and write efficiency of the network port.Python It is a Web server background working language (Douban), so multithreading is naturally supported by the Python language.Multi-threaded ticketin
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.