Working with Concurrency in Go (Golang)

所在平台: Udemy

课程主页: https://www.udemy.com/course/working-with-concurrency-in-go-golang/

课程评论:没有评论

第一个写评论        关注课程

课程简介

课程名称:使用 Go (Golang) 进行并发编程 课程概述:Go,通常称为Golang,以其简便的并发处理而闻名。为了使某个函数并发执行,只需在函数调用前加上“go”关键字,函数便会在后台以 GoRoutine 的形式运行。Go 内置的调度器会负责确保 GoRoutine 在正确的时间高效运行。然而,在 Go 中进行线程安全编程并非易事,它需要仔细的规划,开发者必须对 Go 的并发处理有深入的理解。 Go 的标准库提供了多种处理并发运行部分程序的方式,主要包括:sync.WaitGroup(用于等待任务完成)、sync.Mutex(用于锁定和解锁资源,防止多个 GoRoutine 同时访问同一内存位置)、以及 Channels(允许 GoRoutine 之间发送和接收数据)。Go 的并发处理理念相对直接,核心口号为:“不要通过共享内存进行通信;而是通过通信来共享内存。” Channels 是我们通常用来实现这一理念的工具。 本课程将详细讲解 WaitGroups、Mutexes 和 Channels 的使用,同时探讨并发编程中的一些固有问题,包括程序的早期终止和竞争条件。课程将通过解决计算机科学中的经典问题,如哲学家就餐、生产者/消费者问题和睡眠理发师,帮助学员深入理解并发编程的原理。这些问题的经典性在于,它们迫使开发者找到处理并发或并行代码的最佳方法。 最后,课程将通过解决一个“现实世界”的问题结束,即注册客户订阅服务,处理发票、注册及启动新客户所需的各种任务。我们将通过将必要的任务划分为更小的任务,以并发的方式尽快完成。 请注意,参加本课程需要下载 Docker Desktop 软件。如果您是 Udemy Business 的用户,请在下载软件前咨询您的雇主。

课程评论(0条)

课程详情

Go, often referred to as Golang, is well-known for making it remarkably easy to work with concurrency. In order to make a particular function run concurrently, all we have to do is prepend the word "go" to the function call, and it cheerfully runs in the background, as a GoRoutine. Go's built in scheduler takes are of making sure that a given GoRoutine runs when it should, and as efficiently as it can.However, this does not mean that working with concurrency is simple in Go-thread safe programming takes careful planning, and most importantly it requires that developers have an absolutely solid understanding of how Go deals with concurrency.In the standard library, Go offers us several ways of dealing with concurrently running parts of our program, right in the standard library: sync.WaitGroup, which lets us wait for tasks to finish; sync.Mutex, which allows us to lock and unlock resources, so that no two GoRoutines can access the same memory location at the same time; and finally, Channels, which allow GoRoutines to send and receive data to and from each other.Go's approach to concurrency is fairly straightforward, and is more or less summed up this mantra: Don't communicate by sharing memory; instead, share memory by communicating. Channels are the means by which we usually share memory by communicating. In this course, we'll cover the use of WaitGroups, Mutexes, and Channels, and we'll do so in detail. We'll also cover some of the problems inherent in concurrency, including early program termination and race conditions. Initially, we'll gain a good understanding of how these things work by solving some of the classic problems found in the field of computer science, including the Dining Philosophers, the Producer/Consumer problem, and the Sleeping Barber. These problems are classics for a reason: they force a developer to figure out the best approach to working with code that run concurrently, or in parallel. Finally, we'll finish the course out with a more "real-world" problem, where we have to register a customer for some kind of subscription service, and take care of invoicing, registration, and all the things necessary to get a new customer up and running. We'll do so, naturally, as quickly as we can by dividing the necessary tasks up into smaller tasks, and having them run concurrently.Please note that this course requires you to download Docker Desktop from Docker. If you are a Udemy Business user, please check with your employer before downloading software.

课程标签

0人关注该课程

主题相关的课程