Reader small image

You're reading from  Go Web Scraping Quick Start Guide

Product typeBook
Published inJan 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789615708
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Vincent Smith
Vincent Smith
author image
Vincent Smith

Vincent Smith has been a software engineer for 10 years, having worked in various fields from health and IT to machine learning, and large-scale web scrapers. He has worked for both large-scale Fortune 500 companies and start-ups alike and has sharpened his skills from the best of both worlds. While obtaining a degree in electrical engineering, he learned the foundations of writing good code through his Java courses. These basics helped spur his career in software development early in his professional career in order to provide support for his team. He fell in love with the process of teaching computers how to behave and set him on the path he still walks today.
Read more about Vincent Smith

Right arrow

Concurrency pitfalls

The source of most issues with concurrency is figuring out how to share information safely, and provide access to that information, between multiple threads. The simplest solution would seem to be to have an object that both threads can have access to, and modify, in order to communicate with the other thread. This seemingly innocent strategy is easier suggested than done. Let's look at this example, where two threads are sharing the same stack of web pages to scrape. They will need to know which web pages have been completed, and which web pages the other thread is currently working on.

We will use a simple map for this example, as shown in the following code:

siteStatus := map[string]string{
"http://example.com/page1.html" : "READY",
"http://example.com/page2.html" : "READY",
"http://example.com/page3...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Go Web Scraping Quick Start Guide
Published in: Jan 2019Publisher: PacktISBN-13: 9781789615708

Author (1)

author image
Vincent Smith

Vincent Smith has been a software engineer for 10 years, having worked in various fields from health and IT to machine learning, and large-scale web scrapers. He has worked for both large-scale Fortune 500 companies and start-ups alike and has sharpened his skills from the best of both worlds. While obtaining a degree in electrical engineering, he learned the foundations of writing good code through his Java courses. These basics helped spur his career in software development early in his professional career in order to provide support for his team. He fell in love with the process of teaching computers how to behave and set him on the path he still walks today.
Read more about Vincent Smith