diff --git a/multithread.js b/multithread.js index d8d37c0..596ca10 100644 --- a/multithread.js +++ b/multithread.js @@ -10,7 +10,7 @@ } function Multithread(threads) { - this.threads = Math.max(2, threads | 0); + this.threads = (typeof threads !== 'undefined') ? threads: (typeof navigator.hardwareConcurrency !== 'undefined') ? navigator.hardwareConcurrency : 2 this._queue = []; this._queueSize = 0; this._activeThreads = 0; @@ -266,4 +266,4 @@ window['Multithread'] = Multithread; -}(); \ No newline at end of file +}();