Simple concurrent implementation of a stack?
Using mutexes and sync request on every operation.
type Stack struct {
list *list.List
lock sync.Mutex
}
func (this *Stack) Size() int {
this.lock.Lock()
defer this.lock.Unlock()
return this.list.Len()
}
Explain:
Concurrency vs Parallelism?
Concurrency is about modeling a solution to allow composition of independent processes which execute in the same time.
Parallelism is about simultanious execution or potentially related processes in a parallel way.
Concurrency is not parallelism, but it potentially enables parallelism.
Communicating Sequential Processes - CSP?