Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: boolean while loops "how to stop" and "make room for textout to textarea" Date: Sun, 1 Nov 2020 13:52:52 +0100 Lines: 43 Message-ID: References: <6d2d33cc-9b19-469c-a25c-d8d2f862f0aco@googlegroups.com> <314f637c-5652-49f0-b79c-356f95244328o@googlegroups.com> <2397252d-ca36-4e93-8d73-88816bf4fabeo@googlegroups.com> <72ba1be0-524c-4f9b-aef7-4bae15ab7f20o@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net vgyepC20koIlucCCFhprTgYpDqq9fDXoZqZ2gDCHscVR+JslyQ Cancel-Lock: sha1:UtyNvJC+cn87lvlN9zUVw5gseE0= In-Reply-To: <72ba1be0-524c-4f9b-aef7-4bae15ab7f20o@googlegroups.com> Xref: csiph.com comp.lang.javascript:39078 Jonas Thörnvall: > Den lördag 31 oktober 2020 kl. 18:49:37 UTC+1 skrev Arno Welzel: [...] >> Just creating a loop which never exists as long as "run" is not false >> does not work if this should be something useful in the browser. >> >> That's the reason where there are functions like setTimeout() or >> setInterval() to keep things running in JavaScript while still being >> able to handle events caused by the user. >> >> >> -- >> Arno Welzel >> https://arnowelzel.de > > No you are so wrong Arno, a programming language ***must*** be able to handle. The language has nothing to do with it. I am talking about how a UI and multithreading works in general. If there is only one thread there is no way to handle UI events as long as the thread is inside a while() loop. Do you even know, what threads in software are? > Letting UI set a boolean to stop a loop, javascripts idea of invent idiot syntax to replace the obvious, is so incredible stupid it must been invented by an ENTP. The click event WILL NOT be handled, as long as your code is still inside a loop! > while (run==true){} > > And then from UI call a function to set the run boolean false, is how things should work ***anything else is just nonesense, making no sense***. There is nothing wrong with setInterval and setTimout. But they fucking should not replace set the boolean to false. The problem is, that the click handler will not be called as long as your code is inside the while() loop because there is only one thread which either runs your code OR handles UI events. Please try at least to learn what multithreading and event handling means. -- Arno Welzel https://arnowelzel.de