Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go Web Scraping Quick Start Guide

You're reading from   Go Web Scraping Quick Start Guide Implement the power of Go to scrape and crawl data from the web

Arrow left icon
Product type Paperback
Published in Jan 2019
Publisher Packt
ISBN-13 9781789615708
Length 132 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Vincent Smith Vincent Smith
Author Profile Icon Vincent Smith
Vincent Smith
Arrow right icon
View More author details
Toc

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime