@@ -233,7 +233,7 @@ Let's first create a simple server:
233233``` julia-repl
234234julia> using Sockets
235235
236- julia> errormonitor(@async begin
236+ julia> errormonitor(Threads.@spawn begin
237237 server = listen(2000)
238238 while true
239239 sock = accept(server)
@@ -305,11 +305,11 @@ printed the message and waited for the next client. Reading and writing works in
305305To see this, consider the following simple echo server:
306306
307307``` julia-repl
308- julia> errormonitor(@async begin
308+ julia> errormonitor(Threads.@spawn begin
309309 server = listen(2001)
310310 while true
311311 sock = accept(server)
312- @async while isopen(sock)
312+ Threads.@spawn while isopen(sock)
313313 write(sock, readline(sock, keep=true))
314314 end
315315 end
@@ -319,7 +319,7 @@ Task (runnable) @0x00007fd31dc12e60
319319julia> clientside = connect(2001)
320320TCPSocket(RawFD(28) open, 0 bytes waiting)
321321
322- julia> errormonitor(@async while isopen(clientside)
322+ julia> errormonitor(Threads.@spawn while isopen(clientside)
323323 write(stdout, readline(clientside, keep=true))
324324 end)
325325Task (runnable) @0x00007fd31dc11870
@@ -357,10 +357,10 @@ ip"74.125.226.225"
357357
358358All I/O operations exposed by [ ` Base.read ` ] ( @ref ) and [ ` Base.write ` ] ( @ref ) can be performed
359359asynchronously through the use of [ coroutines] (@ref man-tasks). You can create a new coroutine to
360- read from or write to a stream using the [ ` @async ` ] ( @ref ) macro:
360+ read from or write to a stream using the [ ` Threads.@spawn ` ] ( @ref ) macro:
361361
362362``` julia-repl
363- julia> task = @async open("foo.txt", "w") do io
363+ julia> task = Threads.@spawn open("foo.txt", "w") do io
364364 write(io, "Hello, World!")
365365 end;
366366
@@ -379,7 +379,7 @@ your program to block until all of the coroutines it wraps around have exited:
379379julia> using Sockets
380380
381381julia> @sync for hostname in ("google.com", "github.com", "julialang.org")
382- @async begin
382+ Threads.@spawn begin
383383 conn = connect(hostname, 80)
384384 write(conn, "GET / HTTP/1.1\r\nHost:$(hostname)\r\n\r\n")
385385 readline(conn, keep=true)
0 commit comments