March 2019
Intermediate to advanced
336 pages
9h 9m
English
A synchronized queue consists of elements that need to be processed in a particular sequence. Passenger queue and ticket processing queues are types of synchronized queues, as follows:
//main package has examples shown// in Hands-On Data Structures and algorithms with Go bookpackage main// importing fmt packageimport ( "fmt" "time" "math/rand")// constantsconst ( messagePassStart = iota messageTicketStart messagePassEnd messageTicketEnd)//Queue classtype Queue struct { waitPass int waitTicket int playPass bool playTicket bool queuePass chan int queueTicket chan int message chan int}
We will discuss the different methods of synchronized queue in the following sections.
Read now
Unlock full access