Sleep: Difference between revisions

729 bytes added ,  14 years ago
m (omit JavaScript)
Line 192:
}
}</lang>
 
=={{header|JavaScript}} (in a web browser)==
 
Generally, JavaScript in a web browser is event-loop based and (except for alert()) non-blocking. So, the closest thing possible to the task description is to do something once the specified time has passed.
 
<lang html><html><head><title>RC Sleep The Main Thread</title></head><body>
<form>
<button type="button" onclick="
function write(s) {
var l = document.getElementById('log');
l.appendChild(document.createTextNode(''+s));
l.appendChild(document.createElement('br'));
}
write('Sleeping...');
setTimeout(function () {
write('Awake!');
}, parseFloat(document.getElementById('delay').value));
">Sleep</button> for <input id="delay"> milliseconds.
</form>
<pre id="log"></pre>
</body></html></lang>
 
=={{header|Logo}}==
Line 361 ⟶ 384:
Message("Awake!\n")</lang>
 
{{Omit from|JavaScript}} <!-- does not have a sleep() function. workarounds with busy waiting loops can be found online -->
{{Omit From|Metafont}}
{{omit from|M4}}