/*
* Although we can understand the problem of lock object of synchronous code block and synchronous method, but we do not directly see where to add the lock, where to release the lock, in order to express more clearly how to lock and release the lock, JDK5 later provided a new lock object locks.
*
* Lock:void Lock (): Gets the lock. void Unlock (): Release lock. Reentrantlock is the implementation class for lock.
*/
public class Sellticketdemo {
public static void Main (string[] args) {
Create a Resource object
Sellticket st = new Sellticket ();
Create a three window
thread T1 = new Thread (ST, "Window 1");
Thread t2 = new Thread (ST, "Window 2");
thread t3 = new Thread (St, "Window 3");
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.