About queues, there are many places to use. There are a lot of examples in reality. For example, the hospital registration system, the Bank of the station system, the canteen in line to play rice and so on. On the market again such a line to pick the number of equipment. Their function is basically as follows:
1, the system can be networked online unified hair number;
2, the system can be wireless docking, but also wired connection;
3, the system supports 100 kinds of business above;
4, the system supports a number of waiting area prompts waiting for information, each waiting area voice and display can be independent;
5, Personalized voice can call the customer's business name (hospital version can call patients name) and other information;
6, the number can be in different service category of the Counter window between the transfer, the customer does not have to repeat the queue;
7, with login operation function and exit operation function: Before work starts, enter employee login number to sign in , after the work is over, exit the queuing system, which is very accurate statistics;
8, the image of the machine interface can be personalized customized design replacement;
9, the key customers of the business can be personalized and independent design of the replacement;
10, support through the reader to read customer-related information, Automatically differentiate between VIP customers and ordinary customers, automatically distinguish between the public and private customers, and according to the business organization of the automatic Queuing rules queue;
11, the number of tickets on the machine and the display screen will show the number of people in front of each customer waiting;
12, each business queue customers can freely increase or decrease on demand
13, the number of business waiting for the customer can be independently set in the interface display and can be arbitrary typesetting;
14, the business hours and pause period customers can be completely independent set up;
15, the operation of the employee's increase or decrease and login account can be completely independent change;
16, Voice Call information customers can be completely autonomous according to personalized changes;
17, the display of any display information customers can be completely independent of personalized changes;
18, customers to handle the serial number of business customers can fully independent settings, such as: VIP business or financial services can be set to 1-200, Foreign currency business can be set to 201-500, RMB business set within 501-9999;
19, the business queues handled by the employees can be set priority by themselves;
20, text content on the ticket, pattern, business name, time format, change font and size, Paper length and so on customers can be personalized settings;
21, the system supports playing background music, music repertoire entirely by the customer independent choice;
22, the system support on duty Manager to add monitoring software to deal with a variety of special conditions;
23, System support high-definition plasma display, large screen , TV wall and other display equipment, displaying a wealth of queuing information;
24, the system to support the Internet, remote monitoring can be achieved;
25, the system has extended functions, when the need for statistics and management data, hot key to activate the management software and print;
26, The system can configure the client evaluators and the queuing information (SMS) prompt function according to the need.
OK, after you've learned this, let's implement a simple example. First look at the effect chart:
Don't say much nonsense, look at the code:
Callnum.java
Package com.test;
Import Java.util.concurrent.ExecutorService;
Import java.util.concurrent.Executors;
Import Java.util.concurrent.TimeUnit;
/**
* @see Analogue Bank System
* @author Herman.xiong *
@date November 17, 2014 14:48:48
* @version V1.0
* * public class Callnum {public
static void Main (string[] args) throws Interruptedexception {
//Create a service center, such as a bank's business hall
Center Center = New Center ();
Executorservice exec = Executors.newcachedthreadpool ();
Simulation generates service personnel
Producer Producer = new Producer (center);
Simulation generates n multiple customer
Consumer Consumer = new Consumer (center);
Exec.execute (producer);
Simulate 10 customers for
(int i = 0; i < i++) {
Exec.execute (consumer);
}
TimeUnit.SECONDS.sleep (ten);
Exec.shutdown ();
If you have questions, please add QQ Group: 135430763 study together.
}
}
Center.java
Package com.test;
Import Java.util.Random;
Import Java.util.concurrent.BlockingQueue;
Import Java.util.concurrent.LinkedBlockingQueue;
Import Java.util.concurrent.TimeUnit; /** * @see Service Centre * @author Herman.xiong * @date November 17, 2014 14:41:28 * @version V1.0 * * Public class Center extends Th
Read {private final static int maxcount = 10;
Private blockingqueue<waiter> waiters;
Private blockingqueue<customer> customers;
Private Random rand = new Random (47);
Private final static int producersleepseed = 100;
Private final static int consumersleepseed = 10000;
Public Center () {//Create 10 service-Providing staff this.waiters = new linkedblockingqueue<waiter> (maxcount);
for (int i = 0; i < Maxcount i++) {Waiters.add (new Waiter ());
///10 staff is working, create customer Queue this.customers = new linkedblockingqueue<customer> (); public void Produce () {TRy {TimeUnit.MILLISECONDS.sleep (Rand.nextint (producersleepseed));
catch (Interruptedexception e) {e.printstacktrace ();
} this.customers.add (New Customer ()); The public void consume () {try {//service window is available waiter waiter = This.wa
Iters.take ();
This.waiters.remove (waiter);
Customers can use customer customer = This.customers.take ();
This.customers.remove (customer);
Window display System.out.println (Waiter + "is" + customer + "service ...");
TimeUnit.MILLISECONDS.sleep (Rand.nextint (consumersleepseed));
This.waiters.add (waiter);
catch (Interruptedexception e) {System.err.println ("---" + e.getmessage ()); }
}
}Producer.java
Package com.test;
/**
* @see producer threads, simulation bank staff service completes a customer after the preparation service next customer
* @author herman.xiong
* @date November 17, 2014 14:55:43
* Version V1.0
*
/public class Producer implements Runnable {
Private Center center;
Public Producer (center center) {
this.center = center;
}
@Override public
Void Run () {while
! Thread.interrupted ()) {
//Generate Customer
center.produce ();
}
}
}
Consumer.java
Package com.test;
/**
* @see simulate a customer's business needs, the service staff is free to be ready
* @author herman.xiong
* @date November 17, 2014 14:57:11
* @version V1.0
* * Public
class Consumer implements Runnable {
Private Center center;
Public Consumer (center center) {
this.center = center;
}
@Override public
Void Run () {while
! Thread.interrupted ()) {
center.consume ();}}}
Click Source code to download: http://download.csdn.net/download/xmt1139057136/8167619
About everyone concerned about my blog. If you have questions, please add QQ Group: 135430763 study together.