March 2019
Intermediate to advanced
336 pages
9h 9m
English
The main method calls the passenger and ticketIssue methods after creating a queue. The passenger enters into the queue and a ticket is issued at the counter in the processing queue, as explained in the following code:
// main methodfunc main() { var Queue *Queue = & Queue{} //fmt.Println(Queue) Queue.New() fmt.Println(Queue) var i int for i = 0; i < 10; i++ { // fmt.Println(i, "passenger in the Queue") go passenger(Queue) } //close(Queue.queuePass) var j int for j = 0; j < 5; j++ { // fmt.Println(i, "ticket issued in the Queue") go ticketIssue(Queue) } select {}}
Run the following command to execute the sync_queue.go file:
go run sync_queue.go
After executing the preceding command, we get the following output:
The next section ...
Read now
Unlock full access