LoginSignup
14
14

More than 5 years have passed since last update.

Javascript実行系はマルチスレッドに対応しているのか?

Posted at

結論だけ、書く。

Webブラウザで動くJavascriptは基本シングルスレッドである

HTML5のWeb Workersという新機能でマルチスレッドに対応

setTimeoutなどは非同期のように見えるが,setTimeoutは指定時間後に実行キューに関数を入れるだけ.
setTimeoutした後の処理が長時間かかると指定時間後になっても実行されないこともありえる
参考ページ:http://d.hatena.ne.jp/amachang/20060910/1157911122

例えばsetTimeoutした後に時間のかかる処理を行うと
setTimeoutの関数はその分遅れる
例)http://jsfiddle.net/hA8nR/

Node.jsは原則シングルスレッド

しかし,子プロセスを作ることは可能である.
http://nodejs.org/api/child_process.html

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14