Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
/// Returns the number of trailing zeros in a 32bit unsigned integer. | |
/// | |
/// Hacker's Delight, Reiser's algorithm. | |
/// "Three ops including a "remainder, plus an indexed load." | |
/// | |
/// Works because each bit in the 32 bit integer hash uniquely to the | |
/// prime number 37. The lowest set bit is returned via (x & -x). | |
ntz32(int x) { | |
assert(x < 0x100000000, "only 32bit numbers supported"); | |
return _ntzLut32[(x & -x) % 37]; |
/***************************************** | |
/* DOM touch support module | |
/*****************************************/ | |
if (!window.CustomEvent) { | |
window.CustomEvent = function (event, params) { | |
params = params || { bubbles: false, cancelable: false, detail: undefined }; | |
var evt = document.createEvent('CustomEvent'); | |
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); | |
return evt; | |
}; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.