Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
7ff68b36
Commit
7ff68b36
authored
Dec 13, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go_mem: goroutine exit is not special
R=r CC=golang-dev
https://golang.org/cl/3628041
parent
951318c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
doc/go_mem.html
doc/go_mem.html
+29
-0
No files found.
doc/go_mem.html
View file @
7ff68b36
...
...
@@ -143,6 +143,35 @@ calling <code>hello</code> will print <code>"hello, world"</code>
at some point in the future (perhaps after
<code>
hello
</code>
has returned).
</p>
<h3>
Goroutine destruction
</h3>
<p>
The exit of a goroutine is not guaranteed to happen before
any event in the program. For example, in this program:
</p>
<pre>
var a string
func hello() {
go func() { a = "hello" }()
print(a)
}
</pre>
<p>
the assignment to
<code>
a
</code>
is not followed by
any synchronization event, so it is not guaranteed to be
observed by any other goroutine.
In fact, an aggressive compiler might delete the entire
<code>
go
</code>
statement.
</p>
<p>
If the effects of a goroutine must be observed by another goroutine,
use a synchronization mechanism such as a lock or channel
communiation to establish a relative ordering.
</p>
<h3>
Channel communication
</h3>
<p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment