|The file download and read for the file name will execute in parallel, taking turns until both return. Since both read and http.get yield regularly (the first one waiting for characters, and the second waiting for a response), no deadlocking occurs.|
local handle, file parallel.waitForAll( function() io.write("enter a file name: ") file = fs.open(read(), "w") end, function() handle = http.get("https://example.computercraft.cc") end ) file.writeLine(handle.readAll()) handle.close() file.close()
|Output||Writes the contents of example.computercraft.cc to the filename that the user entered.|
- "CC-Tweaked/parallel.lua". GitHub. 2017-06-12. Retrieved 2018-08-06.