Node.js/线程:修订间差异
来自康健生活
| 第180行: | 第180行: | ||
* 工作进程负载均衡 | * 工作进程负载均衡 | ||
* 工作进程状态共享 | * 工作进程状态共享 | ||
== 多线程下载原理 == | == 多线程 == | ||
* [https://github.com/xk/node-threads-a-gogo threads_a_gogo] | |||
==== threads_a_gogo ==== | |||
部分 api。 | |||
<syntaxhighlight lang="javascript"> | |||
const threadsAGogo = require('threads_a_gogo'); | |||
const threadObject = threadsAGogo.create(/* no arguments */); | |||
const threadPool = threadsAGogo.createPool(/* set thread pool number */); | |||
threadObject.load("test.js").eval("testFun()").emit("go").on("event", cb); | |||
</syntaxhighlight> | |||
=== 多线程下载原理 === | |||
多线程下载首先要获取整个文件的大小,然后开多个线程来下载这个文件的不同部分。 | 多线程下载首先要获取整个文件的大小,然后开多个线程来下载这个文件的不同部分。 | ||
=== 断点下载 === | === 断点下载 === | ||