HelloWorld at the heart of every concurrent problem is a producer and a consumer. So, in our paradigm, our producer is a goroutine, which runs independently and a consumer is also a goroutine which runs independently of the producer. So, the use case is that the producer produces some items which the consumer has to consume, right. So, these are these items are consumed in the first come first serve basis or FIFO basis. And so, it makes better sense to consume these items in a queue. So, this problem this problem is, if there is one producer if there is one producer and one consumer, what what happens if we have multiple consumers?
So, we have number one, we have consumer number two and so on. So, then it becomes a synchronous synchronicity problem because the producers and the humans need to be synchronous with a synchronized with each other. So, we have one thing that should be assigned to this but what happens when both of the consumers try to grab it So here's where channel come in. So channel, what channel is, is it's just, it's just a queue with mutexes. So when we're talking about goroutines and channels paradigm and Gaulin, then keep in mind that whoever talks about goroutines and channels internally is talking about basically a queue and a set of new Texas. So, whatever these items that the producer produces, they go inside the channel.
And then from inside the channel, we can control which consumer gets what. So, this is the theory behind channels and channels can be of multiple types. So they can be one channel, which is buffered. They can be buffered channels, and then they can be unbuffered channels. So unbuffered channels is a channel with whose queue sizes one. And queue size being one or use has been zero rather means that whenever a producer a producer produces something it can't produce anything else.
For this is consumed by the consumer. So let's say we have a queue, a queue is this. And a queue can only hold one item over here. Or it can only hold one item over here, the producer producer produces the item, and the consumer has to consume this item. So our little gopher over here he just consumed this. And then now producer is free to produce one more item.
So this is unbounded, this is a bounded buffer with zero size. And then we have unbounded buffers with a certain limit or limited buffers, which we can hold about two or three q two or three items in the queue. So, a producer produces two items, then the consumer on consumes the first item and then producer can produce one more item while this item is still in the queue. And then the second consumer consumes this item in our first come first serve basis. So this is behind this is a theory behind synchronous and asynchronous queues. This whole process is called inter process communication.
So we have one process, and we have two processes, and we have multiple consumers or we can have multiple producers also. So all of these are independent of each other. So they need to be synchronized with each other. And they need to communicate with each other in a process called inter process communication, which happens in golang using channels. So one more great thing about channels is that it's not like they're using a shared memory. So, channels can channels or data rather, can directly be passed from one go routine to the other goroutine because everything is stored in the form of pointers or references.
So every item that the producer produces is actually a kind of a reference, which can be consumed directly by the consumer and it does does not need to access it from a shared memory pool. So in this video, we talked about producers consumers channels go routines, and how goroutines and channels paradigm is just another name for queues and mutex. This