![]() ![]() So then, let's not give them tools that are so easy to misuse that every other website i open ends up crashing my browser. While restrictive, this will likely be the most practical design for the near future, both because it simplifies the design of the browser, and because it reduces the risk involved in allowing inexperienced JS coders mess around with is that a reason not to implement multi-threading in Javascript? Programmers can do whatever they want with the tools they have. Google Gears side-steps a lot of potential problems by requiring that background execution is isolated - no changing the DOM (since that's not thread-safe), no accessing objects created by the main thread (ditto). But, it'll take a bit for browsers to catch up - most of them have been designed around a single-threaded model, and changing that is not easy. If you had major calculations going on, you did it on a server - the idea of a JS+HTML app that ran in your browser for long periods of time doing non-trivial things was absurd. ![]() Traditionally, JS was intended for short, quick-running pieces of code. I don’t think it will ever be implemented in the language itself, since true multi-threading is only useful if the browser can run a single page multi-threaded (or even more than one core), and the difficulties there are way larger than the extra possibilities.įor the future of JavaScript, check this out: This allows some form of scheduling and fakes parallelism, starting and stopping of threads, etcetera, but it will not be true multi-threading. This allows us to run actions in the following manner: We use an abstraction library in JavaScript that allows us to create processes and threads which are all managed by the same JavaScript interpreter. coordinates and updating an element accordingly will just let you see the start and end positions, and nothing in between. This is very useful if you want to allow the viewport (what you see) to refresh while performing operations on it. This causes the browser to regain control of the rendering thread, and start the JavaScript code supplied to setTimeout after the given number of milliseconds. You can however use, as was suggested, setTimeout to allow some sort of scheduling and “fake” concurrency. All Chrome does is separate multiple components (different tabs, plug-ins, etcetera) into separate processes, but I can’t imagine a single page having more than one JavaScript thread. Even Google Chrome will not let a single web page’s JavaScript run concurrently because this would cause massive concurrency issues in existing web pages. JavaScript does not support multi-threading because the JavaScript interpreter in the browser is a single thread (AFAIK).
0 Comments
Leave a Reply. |