Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39079

Re: boolean while loops "how to stop" and "make room for textout to textarea"

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.javascript
Subject Re: boolean while loops "how to stop" and "make room for textout to textarea"
Date Sun, 1 Nov 2020 14:02:03 +0100
Lines 41
Message-ID <i07puaFkcmpU1@mid.individual.net> (permalink)
References <6d2d33cc-9b19-469c-a25c-d8d2f862f0aco@googlegroups.com> <i05kv9F6nc1U2@mid.individual.net> <c803369b-8162-4ea3-811f-c3f4778ba4aeo@googlegroups.com> <i05mjrF72lpU1@mid.individual.net> <df4ee5e0-173e-40d1-867e-35bfb991f549o@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace individual.net pgMSCkIaYfRArMx/e9XJFACKVwm2EkROyKF1FaFbl5I1TPT69q
Cancel-Lock sha1:UE0ZhU60lwARMjeJbgzN+81lbiQ=
In-Reply-To <df4ee5e0-173e-40d1-867e-35bfb991f549o@googlegroups.com>
Xref csiph.com comp.lang.javascript:39079

Show key headers only | View raw


Jonas Thörnvall:

> Den lördag 31 oktober 2020 kl. 18:53:09 UTC+1 skrev Arno Welzel:
>> Jonas Thörnvall:
>>
>> [...]
>>> Have no idea what you talk about answer why javascript do not stop
>>> loop when condition get false "boolean", and why it do not
>>> ***manage*** to print out to form while in loop, much more
>>> interesting question.
>>
>> JavaScript *is* able to do this. However you try to run a endless loop
>> in a *browser* and wonder why the browser does not handle input as long
>> as the loop runs. You just don't understand what "event driven"
>> programming means.
> 
> You are funny the event we talk about is pushing the button and it work perfectly, what does not work is javascript handling it, apparently it is occupied within a loop. So maybe it is just a case of javascript being single threaded.

Finally you get it! Yes JavaScript in a browser *is* single threaded!
And therefore you MUST NOT build code which constantly runs something in
a loop if you want to have user interaction as well.

> That is basicly what i want to know, why aren't boolean while loops run in separate threads? 

Because there are no separate threads.

If you want to run stuff in the background separate from the UI you
either have to "emulate" this by using setTimeout() or setInterval() and
let a background task only run one step every 1/100 second or you use
web workers to run a script separate from the UI in background:

<https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API>

Workers are also supported by literally all current browsers:

<https://caniuse.com/webworkers>


-- 
Arno Welzel
https://arnowelzel.de

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 03:44 -0700
  Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 04:20 -0700
    Re: boolean while loops "how to stop" and  "make room for textout to textarea" Julio Di Egidio <julio@diegidio.name> - 2020-10-31 06:07 -0700
      Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 09:41 -0700
      Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 09:45 -0700
      Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 09:48 -0700
        Re: boolean while loops "how to stop" and  "make room for textout to textarea" Julio Di Egidio <julio@diegidio.name> - 2020-10-31 10:10 -0700
          Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 10:42 -0700
      Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 10:05 -0700
        Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-10-31 18:49 +0100
          Re: boolean while loops "how to stop" and "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 11:07 -0700
            Re: boolean while loops "how to stop" and "make room for textout to textarea" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-11-01 11:39 +0000
            Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-01 13:52 +0100
      Re: boolean while loops "how to stop" and  "make room for textout to textarea" Julio Di Egidio <julio@diegidio.name> - 2020-11-01 21:57 -0800
        Re: boolean while loops "how to stop" and  "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-01 23:44 -0800
  Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-10-31 18:24 +0100
    Re: boolean while loops "how to stop" and "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 10:44 -0700
      Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-10-31 18:52 +0100
        Re: boolean while loops "how to stop" and "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-31 11:14 -0700
          Re: boolean while loops "how to stop" and "make room for textout to textarea" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-11-01 11:45 +0000
            Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-01 14:02 +0100
              Re: boolean while loops "how to stop" and "make room for textout to textarea" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-11-01 17:38 +0000
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-01 21:07 +0100
                Re: boolean while loops "how to stop" and "make room for textout to textarea" John G Harris <niam@jghnorth.org.uk.invalid> - 2020-11-02 19:36 +0000
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-03 18:34 +0100
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Julio Di Egidio <julio@diegidio.name> - 2020-11-03 11:48 -0800
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-04 15:17 +0100
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-04 15:18 +0100
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Julio Di Egidio <julio@diegidio.name> - 2020-11-04 12:52 -0800
                Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-05 16:12 +0100
          Re: boolean while loops "how to stop" and "make room for textout to textarea" Arno Welzel <usenet@arnowelzel.de> - 2020-11-01 14:02 +0100
  Re: boolean while loops "how to stop" and "make room for textout to textarea" "sc...@sauyet.com" <scott@sauyet.com> - 2020-11-03 13:27 -0800
    Re: boolean while loops "how to stop" and "make room for textout to textarea" Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-03 14:08 -0800
      Re: boolean while loops "how to stop" and "make room for textout to textarea" Scott Sauyet <scott.sauyet@gmail.com> - 2020-11-03 17:28 -0800

csiph-web