[Project_owners] Sleep or wait function for JavaScript

Didier Ernotte dernotte at yahoo.com
Mon Oct 27 12:24:49 PDT 2008

Javascript is not multiThreaded, you have to implement it manually with "yield" and "next".


--- On Mon, 10/27/08, joe ertaba <belaviyo at gmail.com> wrote:
From: joe ertaba <belaviyo at gmail.com>
Subject: [Project_owners] Sleep or wait function for JavaScript
To: "Mozdev Project Owners List" <project_owners at mozdev.org>
Date: Monday, October 27, 2008, 3:06 PM


I need to add sleep function in some procedure, I found some sleep function

function sleep(mTime)
  var sleeping = true;
  var now = new Date();
  var alarm;
  var startingMSeconds = now.getTime();

     alarm = new Date();
     alarmMSeconds = alarm.getTime();
     if(alarmMSeconds - startingMSeconds > mTime)
        sleeping = false; 

but it causes program to hang, any better sleep function ?

P.S: I cant use setTimeout function either

Project_owners mailing list
Project_owners at mozdev.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20081027/2a0ad2ea/attachment.html>

More information about the Project_owners mailing list