Javascript sleep
-
function sleep(milliSeconds) {
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}function verifySleep(milliSeconds) {
// wrapper function so add time tracking for demo
var startTime = new Date().getTime(); // get the current time
sleep(milliSeconds);
alert('blocked for ' + ((new Date().getTime()) - startTime) + ' milli seconds');
}Curvature of the Mind now with 3D
-
function sleep(milliSeconds) {
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}function verifySleep(milliSeconds) {
// wrapper function so add time tracking for demo
var startTime = new Date().getTime(); // get the current time
sleep(milliSeconds);
alert('blocked for ' + ((new Date().getTime()) - startTime) + ' milli seconds');
}Curvature of the Mind now with 3D
What's wrong with that? That's how scroll lock was implemented in the original PC BIOS (and no doubt a zillion clones). Back in the good ol' days, IBM actually published BIOS listings! Cheers, Peter ;P
Software rusts. Simon Stephenson, ca 1994.
-
What's wrong with that? That's how scroll lock was implemented in the original PC BIOS (and no doubt a zillion clones). Back in the good ol' days, IBM actually published BIOS listings! Cheers, Peter ;P
Software rusts. Simon Stephenson, ca 1994.
-
Missed the joke icon?
Software rusts. Simon Stephenson, ca 1994.
-
Missed the joke icon?
Software rusts. Simon Stephenson, ca 1994.