Requirement: Assume the total number of votes is 100 sheetsSuppose there are 5 people in line to sell tickets, and only one person can buy tickets at the same time.After the tickets are sold, the number of votes is reduced.Code:/** * */ Packagecom.niit.homework;/** * @author: Annie * @date: June 16, 2016 * @description: Assuming the total number of votes is 100 fake there are 5 people lined up to sell tickets at the same time only There's a man who buys a ticket and sells it, and the number of
#connection.owner=:=setuppid-> ets:insert (sys_dist,conn#connection{state=up,address=address, Waiting=[],type=type}), setuppid!{self (), inserted},reply_waiting (node,conn#connection.waiting,true), {noreply,state};_->setuppid!{self (), bad_ Request},{noreply,state}end; Update the status in ETS and send a message to all waiting processes to tell them that the remote connection has been successful and you can proceed with the next operation. This time you will be surprised to find out, where is t
/**ABC Three ticket sales window for 50 tickets. Requirements: can be sold at the same time, and cannot sell overlapping, and can not exceed 50 synchronous code block synchronized (object) { synchronous code block;} objects are like locks, A thread holding a lock can execute a thread that does not hold a lock in the synchronization, even if it obtains the CPU's executor. Synchronization Prerequisites: 1. Multithreaded code blocks need to be synchronized, that is, the code in run needs to be sync
Alt+/a class quickly. such as the Scanner class. Re-enter the time can scan here when the use of "alt+/" then you will find and scanner related to the following pull-down menu of the way to bounce out, here to choose the firstScanner class will be directly out, while the first line of code to join the import java.util.scanner.*;Scanner is an input class, Java does not automatically load, using this class requires import of this package.Select multiple lines: shift+↑ or shift+↓ select Multiline p
inheritance define recommendations using implementation two ways to differentiate: inheritance thread: Thread code is stored in ThreaD Subclass the Run method. Implementation runnable: Thread code stored in the interface of the subclass of the Run method, */ classtickimplements runnable { privateinttick=50; publicvoidrun () { while (true) { if (tick>0) system.out.println (thread.currentthread (). GetName () + "sail --"+tick--"; } }} classtickdemo { nBsp;publicstaticvoidmain (S
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.