Introduction to Go, part 14: Goroutines

In this video, goroutines are introduced as well as some of the tools that are available to simply working with them.

Topics covered include:
– creating goroutines
– synchronizing goroutines
– controlling the level of parallelism in an application
– best practices

Follow me on Twitter @vansimke

For more training videos, feel free to check out my videos at
Pluralsight.com (https://www.pluralsight.com/authors/mike-vansickle)
where I have courses on Go, JavaScript, and many other topics.

If you aren’t familiar with Pluralsight and you want to check it out,
just let me know in the comments and I’ll get you setup with a 30-day trial.

Comments

Melpomenex says:

Thank you a lot for this informative video.

Prasad Surase says:

One thing to keep in mind when iterating over multiple values(array/slice), and passing the address of the variable(that holds the value for that iteration) to the go routine will also result in inconsistent output. IMO, always pass the go routine the actual value and not the address of the value.

Hindol Adhya says:

This video is really well made. Learnt a lot! Thanks!

Mage Front says:

Let’s say we have 100 tickets and 4 terminals to sell them, I can’t seem to find a better way than read write locks.

Chanlito says:

I’m coming from nodejs. Go seems weird.

paracha3 says:

love your work. very concise and well organized teaching style

Juulleeeeh says:

Hi I just want to ask what editor you’re using. I’m sure that’s not atom and definitely not sublime. Thank you!

Saurabh Mehta says:

This is sooooo helpful. I loved your teaching style.

Tudor Hulban says:

the code is dificult to follow on my 5.2 phone screen. i would hide left section to increase size at least twice.

Priyansh Sangule says:

Wow! Why is your content so underrated? It’s worth every bit of the effort you put! Thanks again!

Quasi84 says:

You should pass the waitgroup by reference into the functions. That way, you can put the wg declaration inside main and not have a global wg hanging around.

It becomes more clear what’s going on when you read the code and you can more quickly understand the code and do less scrolling. By keeping things to arguments, you will make it easier to see what the function needs. It will be very clear what the function needs from the outside world and you’ll avoid running into the trouble of renaming variables during refactoring when the program grows since things are in scope at all times.

So unless something really needs to be global, there’s no reason for it to be global. Most things can still be passed around as arguments.

I think this is a better practice, don’t you?

https://bpaste.net/show/aa18fd89393e

Geo Trump says:

This was an excellent video. You explained it better than anyone has ever done for me before!!!!

mahedi hasan says:

hi

Tiago Melo says:

Very clear explanation!

Engineering Programming says:

excellent!!

Nico Calvo says:

You made everything so simple. Thanks for your effort.

V20 User says:

I’m a bit lose in mutex part. So using mutex in go routine will ignore the benefit of pararellism since it will run on single thread?

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Bicycles   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Kinis Swimwear   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion Hats   Modeling TipsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Hiking & Trek Gear   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   Vapes   GameplaysHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Audio HiFi   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Tools Workshop   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours