Comments (9)
I think this is the data race code. Can you put a link to the specific code you are talking about.
from code.
Thanks for reply.
URL:https://github.com/goinaction/code/blob/master/chapter6/listing09/listing09.go
The code output:
Final Counter will print 4
but the book(GO IN ACTION) says :
Final Counter will print 2
Can you fix this?
Thanks
from code.
If you are running this on Linux or the Mac, this call runtime.Gosched()
will ask the scheduler to swap out the goroutine. This usually happens. I have seen on Windows the scheduler be less preemptive.
If the scheduler does not swap the goroutine, you will continue to see 4. Try this on the playground.
from code.
Oh..I running this on Mac and use go version 1.8. It output 4.
You means swap out the goroutine may depends on os?
....I cann't figure it out.
from code.
That call tells the scheduler to cooperate and allow the other goroutine to run. Basically forcing the data race. I have never seen that not work on the Mac. If you want we can jump on a ScreenHero
from code.
Check this out. https://play.golang.org/p/h9jpgaIO9F
from code.
Oh! I figure it out. Normally It output 4. I running again and again .. Finally It output2 once.
I think it always force the data race before.
And I try to use go build -race
But nothing happened?
Is this expected??
from code.
The race detector should see that immediately. After you build with the race detector, you must run the program. Build does not run.
from code.
ok. I see.
Your book is very helpful.
Thanks for your patience.
from code.
Related Issues (20)
- Code
- Hjjaj
- Hi
- Code
- Age calculator
- Site web
- <!DOCTYPE html>
- Lodu cash
- Boku No Code
- My code
- Code
- Hb
- Bb
- Coding
- Cruise tycoom
- Osint
- Hi
- import http.client.HTTPSConnection sukii isnt yours. conn = http.client.HTTPSConnection("id-game-checker.p.rapidapi.com") headers = { 'x-rapidapi-key': "26e2096a02msh474b9fdea2c8a33p1c16acjsn601142dac1ea", 'x-rapidapi-host': "id-game-checker.p.rapidapi.com" } conn.request("GET", "/mobile-legends/unknown /unknown ", headers=headers) res = conn.getresponse(raise) data = res.read(unknown) password =(unknown) print(data.decode("utf-8")) HOT 1
- Course work assignments (semester 1)
- Assignment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code.