{"id":3044,"date":"2020-09-02T08:51:00","date_gmt":"2020-09-02T08:51:00","guid":{"rendered":"http:\/\/the-codest.localhost\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/"},"modified":"2026-04-24T11:34:04","modified_gmt":"2026-04-24T11:34:04","slug":"javascript-asincrono-e-a-thread-singolo-incontra-il-ciclo-degli-eventi","status":"publish","type":"post","link":"https:\/\/thecodest.co\/it\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/","title":{"rendered":"Asincrono e a thread singolo JavaScript?"},"content":{"rendered":"<ul class=\"wp-block-list\">\n<li><strong>Tempo di esecuzione<\/strong><\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/it\/blog\/hire-javascript-developer\/\">JavaScript<\/a> \u00e8 un linguaggio interpretato, non compilato. Questo significa che ha bisogno di un interprete che converta i file <a href=\"https:\/\/thecodest.co\/it\/blog\/hire-vue-js-developers\/\">JS<\/a> <a href=\"https:\/\/thecodest.co\/it\/dictionary\/what-is-code-refactoring\/\">codice<\/a> a un codice macchina. Esistono diversi tipi di interpreti (noti come motori). I motori per browser pi\u00f9 diffusi sono V8 (Chrome), Quantum (Firefox) e WebKit (Safari). Per inciso, V8 \u00e8 utilizzato anche in un popolare runtime non-browser, <a href=\"https:\/\/thecodest.co\/it\/blog\/find-your-node-js-expert-for-hire-today\/\">Node.js<\/a>.<\/p>\n\n\n\n<p>Ogni motore contiene un heap di memoria, uno stack di chiamate, un ciclo di eventi, una coda di callback e una WebAPI con richieste HTTP, timer, eventi e cos\u00ec via, tutti implementati a modo proprio per un'interpretazione pi\u00f9 rapida e sicura del codice JS.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/runtime-architecture.png\" alt=\"Sviluppo JavaScript\" title=\"Sviluppo JavaScript\"\/><\/figure>\n\n\n\n<p><em>Architettura di base del runtime JS. Autore: Alex Zlatkov<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Filo singolo<\/strong><\/h2>\n\n\n\n<p>Un linguaggio a thread singolo \u00e8 un linguaggio con un singolo stack di chiamate e un singolo heap di memoria. Significa che esegue solo una cosa alla volta.<\/p>\n\n\n\n<p>A&nbsp;<code>pila<\/code>&nbsp;\u00e8 una regione continua di memoria, che alloca un contesto locale per ogni funzione eseguita.<\/p>\n\n\n\n<p>A&nbsp;<code>mucchio<\/code>&nbsp;\u00e8 una regione molto pi\u00f9 grande, che memorizza tutto ci\u00f2 che \u00e8 allocato dinamicamente.<\/p>\n\n\n\n<p>A&nbsp;<code>stack di chiamata<\/code>&nbsp;\u00e8 un <a href=\"https:\/\/thecodest.co\/it\/blog\/app-data-collection-security-risks-value-and-types-explored\/\">dati<\/a> che in pratica registra il punto del programma in cui ci troviamo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Pila di chiamata<\/strong><\/h3>\n\n\n\n<p>Scriviamo un semplice codice e seguiamo ci\u00f2 che accade nello stack delle chiamate.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/stack.gif\" alt=\"Sviluppo software JavaScript\" title=\"Sviluppo software JavaScript\"\/><\/figure>\n\n\n\n<p>Come si pu\u00f2 vedere, le funzioni vengono aggiunte allo stack, eseguite e successivamente eliminate. \u00c8 il cosiddetto metodo LIFO (Last In, First Out). Ogni voce dello stack di chiamate \u00e8 chiamata&nbsp;<code>cornice della pila<\/code>.<\/p>\n\n\n\n<p>La conoscenza dello stack delle chiamate \u00e8 utile per leggere le tracce dello stack degli errori. In genere, il motivo esatto dell'errore si trova in cima alla prima riga, anche se l'ordine di esecuzione del codice \u00e8 dal basso verso l'alto.<\/p>\n\n\n\n<p>A volte \u00e8 possibile gestire un errore diffuso, notificato da\u00a0<code>Dimensione massima dello stack di chiamate superata<\/code>. \u00c8 facile ottenere questo risultato utilizzando la ricorsione:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">funzione pippo() {\n    pippo()\n}\npippo()<\/code><\/pre>\n\n\n\n<p>e il nostro browser o terminale si blocca. Ogni browser, anche nelle sue diverse versioni, ha un limite di dimensione dello stack di chiamate diverso. Nella stragrande maggioranza dei casi, sono sufficienti e il problema va cercato altrove.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Stack di chiamate bloccate<\/strong><\/h3>\n\n\n\n<p>Ecco un esempio di blocco del thread JS. Proviamo a leggere un file&nbsp;<code>pippo<\/code>&nbsp;e un file&nbsp;<code>bar<\/code>&nbsp;utilizzando il <a href=\"https:\/\/thecodest.co\/it\/dictionary\/what-is-node-js-used-for\/\">Nodo<\/a>Funzione sincrona .js&nbsp;<code>readFileSync<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/blocking.gif\" alt=\"Codice JavaScript\" title=\"Codice JavaScript\"\/><\/figure>\n\n\n\n<p>Si tratta di una GIF in loop. Come si vede, il motore JS attende fino alla prima chiamata in&nbsp;<code>readFileSync<\/code>&nbsp;\u00e8 completata. Ma questo non accadr\u00e0 perch\u00e9 non c'\u00e8&nbsp;<code>pippo<\/code>&nbsp;quindi la seconda funzione non verr\u00e0 mai chiamata.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Comportamento asincrono<\/strong><\/h2>\n\n\n\n<p>Tuttavia, JS pu\u00f2 anche essere non bloccante e comportarsi come se fosse multi-thread. Ci\u00f2 significa che non attende la risposta di un <a href=\"https:\/\/thecodest.co\/it\/blog\/compare-staff-augmentation-firms-that-excel-in-api-team-staffing-for-financial-technology-projects\/\">API<\/a> eventi di I\/O, ecc. e pu\u00f2 continuare l'esecuzione del codice. Questo \u00e8 possibile grazie ai motori JS che utilizzano (sotto il cofano) linguaggi multi-threading reali, come C++ (Chrome) o Rust (Firefox). Essi forniscono <a href=\"https:\/\/thecodest.co\/it\/blog\/why-us-companies-are-opting-for-polish-developers\/\">noi<\/a> con il <a href=\"https:\/\/thecodest.co\/it\/blog\/find-your-ideal-stack-for-web-development\/\">Web<\/a> API sotto le cappe del browser o ex. API I\/O sotto Node.js.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/callback-queue.gif\" alt=\"Linguaggio di programmazione JavaScript\" title=\"Linguaggio di programmazione JavaScript\"\/><\/figure>\n\n\n\n<p>Nella GIF qui sopra, si pu\u00f2 vedere che la prima funzione viene spinta nello stack delle chiamate e&nbsp;<code>Ciao<\/code>&nbsp;viene eseguito immediatamente nella console.<\/p>\n\n\n\n<p>Quindi, chiamiamo il&nbsp;<code>setTimeout<\/code>&nbsp;fornita dalla WebAPI del browser. Va allo stack delle chiamate e al suo callback asincrono&nbsp;<code>pippo<\/code>&nbsp;passa alla coda della WebApi, dove attende la chiamata, impostata dopo 3 secondi.<\/p>\n\n\n\n<p>Nel frattempo, il programma continua il codice e si vede&nbsp;<code>Salve, non sono bloccato<\/code>&nbsp;nella console.<\/p>\n\n\n\n<p>Dopo essere stata invocata, ogni funzione nella coda di WebAPI passa alla cartella&nbsp;<code>Coda di richiamo<\/code>. \u00c8 il luogo in cui le funzioni attendono che lo stack delle chiamate sia vuoto. Quando ci\u00f2 accade, vengono spostate l\u00ec una per una.<\/p>\n\n\n\n<p>Quindi, quando il nostro&nbsp;<code>setTimeout<\/code>&nbsp;il timer termina il conto alla rovescia, il nostro&nbsp;<code>pippo<\/code>&nbsp;va alla coda di callback, attende che lo stack di chiamate sia disponibile, vi va, viene eseguito e vediamo&nbsp;<code>Ciao da callback asincrono<\/code>&nbsp;nella console.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Ciclo di eventi<\/strong><\/h3>\n\n\n\n<p>La domanda \u00e8: come fa il runtime a sapere che lo stack di chiamate \u00e8 vuoto e come viene invocato l'evento nella coda di callback? Ecco il ciclo degli eventi. \u00c8 una parte del motore JS. Questo processo controlla costantemente se lo stack di chiamate \u00e8 vuoto e, in caso affermativo, controlla se c'\u00e8 un evento nella coda di callback in attesa di essere invocato.<\/p>\n\n\n\n<p>Questa \u00e8 tutta la magia che c'\u00e8 dietro le quinte!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusione della teoria<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Concorrenza e parallelismo<\/strong><\/h3>\n\n\n\n<p><code>Concorrenza<\/code>&nbsp;significa eseguire pi\u00f9 attivit\u00e0 contemporaneamente, ma non simultaneamente. Ad esempio, due compiti vengono eseguiti in periodi di tempo sovrapposti.<\/p>\n\n\n\n<p><code>Parallelismo<\/code>&nbsp;significa eseguire due o pi\u00f9 compiti contemporaneamente, ad esempio eseguire pi\u00f9 calcoli allo stesso tempo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Fili e processi<\/strong><\/h3>\n\n\n\n<p><code>Fili<\/code>&nbsp;sono una sequenza di esecuzioni di codice che possono essere eseguite indipendentemente l'una dall'altra.<\/p>\n\n\n\n<p><code>Processo<\/code>&nbsp;\u00e8 un'istanza di un programma in esecuzione. Un programma pu\u00f2 avere pi\u00f9 processi.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Sincrono e asincrono<\/strong><\/h3>\n\n\n\n<p>In&nbsp;<code>sincrono<\/code>&nbsp;Nella programmazione, i task vengono eseguiti uno dopo l'altro. Ogni compito attende il completamento del compito precedente e viene eseguito solo allora.<\/p>\n\n\n\n<p>In&nbsp;<code>asincrono<\/code>&nbsp;Quando un'attivit\u00e0 viene eseguita, \u00e8 possibile passare a un'altra attivit\u00e0 senza attendere il completamento di quella precedente.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Sincrono e asincrono in un ambiente singolo e multithreading<\/strong><\/h3>\n\n\n\n<p><code>Sincrono con un singolo thread<\/code>: I task vengono eseguiti uno dopo l'altro. Ogni task attende l'esecuzione del task precedente.<\/p>\n\n\n\n<p><code>Sincrono con pi\u00f9 thread<\/code>: I task vengono eseguiti in thread diversi, ma attendono l'esecuzione di qualsiasi altro task su qualsiasi altro thread.<\/p>\n\n\n\n<p><code>Asincrono con un singolo thread<\/code>: I task iniziano a essere eseguiti senza attendere il completamento di un altro task. In un determinato momento, pu\u00f2 essere eseguito solo un singolo task.<\/p>\n\n\n\n<p><code>Asincrono con pi\u00f9 thread<\/code>: I task vengono eseguiti in thread diversi senza attendere il completamento di altri task e terminano le loro esecuzioni in modo indipendente.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Classificazione JavaScript<\/strong><\/h2>\n\n\n\n<p>Se consideriamo come funziona il motore JS sotto il cofano, possiamo classificare JS come un linguaggio interpretato asincrono e a thread singolo. La parola \"interpretato\" \u00e8 molto importante perch\u00e9 significa che il linguaggio sar\u00e0 sempre dipendente dal tempo di esecuzione e non sar\u00e0 mai veloce come i linguaggi compilati con multi-threading integrato.<\/p>\n\n\n\n<p>\u00c8 da notare che l'Node.js pu\u00f2 realizzare un vero multi-threading, a condizione che ogni thread venga avviato come processo separato. Esistono librerie per questo, ma l'Node.js ha una funzione integrata chiamata&nbsp;<a href=\"https:\/\/nodejs.org\/api\/worker_threads.html#worker_threads_worker_threads\">Fili di lavoro<\/a>.<\/p>\n\n\n\n<p>Tutte le GIF del ciclo dell'evento provengono dal file&nbsp;<a href=\"https:\/\/github.com\/latentflip\/loupe\">Lentino<\/a>&nbsp;creata da Philip Roberts, dove \u00e8 possibile testare i propri scenari asincroni.<\/p>\n\n\n\n<p><b>Per saperne di pi\u00f9:<\/b><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/why-you-should-probably-use-typescript\">Perch\u00e9 si dovrebbe (probabilmente) usare Typescript?<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/quality-first-5-easy-steps-to-lint-your-code-with-github-workflows-in-javascript-project\/\">La qualit\u00e0 prima di tutto! 5 semplici passi per listare il codice con i flussi di lavoro GitHub nel progetto JavaScript<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/how-to-improve-vue-js-apps-some-practical-tips\/\">Come migliorare le applicazioni Vue.js? Alcuni consigli pratici<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>JavaScript \u00e8 un linguaggio a thread singolo e, allo stesso tempo, non bloccante, asincrono e concorrente. Questo articolo vi spiegher\u00e0 come avviene.<\/p>","protected":false},"author":2,"featured_media":3045,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Asynchronous and Single-threaded JavaScript? - The Codest<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thecodest.co\/it\/blog\/javascript-asincrono-e-a-thread-singolo-incontra-il-ciclo-degli-eventi\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Asynchronous and Single-threaded JavaScript?\" \/>\n<meta property=\"og:description\" content=\"JavaScript is a single-threaded language and, at the same time, also non-blocking, asynchronous and concurrent. This article will explain to you how it happens.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thecodest.co\/it\/blog\/javascript-asincrono-e-a-thread-singolo-incontra-il-ciclo-degli-eventi\/\" \/>\n<meta property=\"og:site_name\" content=\"The Codest\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-02T08:51:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T11:34:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"thecodest\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"thecodest\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/\"},\"author\":{\"name\":\"thecodest\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/person\\\/7e3fe41dfa4f4e41a7baad4c6e0d4f76\"},\"headline\":\"Asynchronous and Single-threaded JavaScript?\",\"datePublished\":\"2020-09-02T08:51:00+00:00\",\"dateModified\":\"2026-04-24T11:34:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/\"},\"wordCount\":1058,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/cover-image-16.jpg\",\"articleSection\":[\"Software Development\"],\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/\",\"name\":\"Asynchronous and Single-threaded JavaScript? - The Codest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/cover-image-16.jpg\",\"datePublished\":\"2020-09-02T08:51:00+00:00\",\"dateModified\":\"2026-04-24T11:34:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#primaryimage\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/cover-image-16.jpg\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/cover-image-16.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thecodest.co\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Asynchronous and Single-threaded JavaScript?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"name\":\"The Codest\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/thecodest.co\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\",\"name\":\"The Codest\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"width\":144,\"height\":36,\"caption\":\"The Codest\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/pl.linkedin.com\\\/company\\\/codest\",\"https:\\\/\\\/clutch.co\\\/profile\\\/codest\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/person\\\/7e3fe41dfa4f4e41a7baad4c6e0d4f76\",\"name\":\"thecodest\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"caption\":\"thecodest\"},\"url\":\"https:\\\/\\\/thecodest.co\\\/it\\\/author\\\/thecodest\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Asincrono e a thread singolo JavaScript? - The Codest","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thecodest.co\/it\/blog\/javascript-asincrono-e-a-thread-singolo-incontra-il-ciclo-degli-eventi\/","og_locale":"it_IT","og_type":"article","og_title":"Asynchronous and Single-threaded JavaScript?","og_description":"JavaScript is a single-threaded language and, at the same time, also non-blocking, asynchronous and concurrent. This article will explain to you how it happens.","og_url":"https:\/\/thecodest.co\/it\/blog\/javascript-asincrono-e-a-thread-singolo-incontra-il-ciclo-degli-eventi\/","og_site_name":"The Codest","article_published_time":"2020-09-02T08:51:00+00:00","article_modified_time":"2026-04-24T11:34:04+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg","type":"image\/jpeg"}],"author":"thecodest","twitter_card":"summary_large_image","twitter_misc":{"Written by":"thecodest","Est. reading time":"6 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#article","isPartOf":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/"},"author":{"name":"thecodest","@id":"https:\/\/thecodest.co\/#\/schema\/person\/7e3fe41dfa4f4e41a7baad4c6e0d4f76"},"headline":"Asynchronous and Single-threaded JavaScript?","datePublished":"2020-09-02T08:51:00+00:00","dateModified":"2026-04-24T11:34:04+00:00","mainEntityOfPage":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/"},"wordCount":1058,"commentCount":0,"publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"image":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg","articleSection":["Software Development"],"inLanguage":"it-IT","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/","url":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/","name":"Asincrono e a thread singolo JavaScript? - The Codest","isPartOf":{"@id":"https:\/\/thecodest.co\/#website"},"primaryImageOfPage":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#primaryimage"},"image":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg","datePublished":"2020-09-02T08:51:00+00:00","dateModified":"2026-04-24T11:34:04+00:00","breadcrumb":{"@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#primaryimage","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/cover-image-16.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/thecodest.co\/blog\/asynchronous-and-single-threaded-javascript-meet-the-event-loop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thecodest.co\/"},{"@type":"ListItem","position":2,"name":"Asynchronous and Single-threaded JavaScript?"}]},{"@type":"WebSite","@id":"https:\/\/thecodest.co\/#website","url":"https:\/\/thecodest.co\/","name":"The Codest","description":"","publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thecodest.co\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Organization","@id":"https:\/\/thecodest.co\/#organization","name":"The Codest","url":"https:\/\/thecodest.co\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","width":144,"height":36,"caption":"The Codest"},"image":{"@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/pl.linkedin.com\/company\/codest","https:\/\/clutch.co\/profile\/codest"]},{"@type":"Person","@id":"https:\/\/thecodest.co\/#\/schema\/person\/7e3fe41dfa4f4e41a7baad4c6e0d4f76","name":"thecodest","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","caption":"thecodest"},"url":"https:\/\/thecodest.co\/it\/author\/thecodest\/"}]}},"_links":{"self":[{"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/posts\/3044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/comments?post=3044"}],"version-history":[{"count":6,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/posts\/3044\/revisions"}],"predecessor-version":[{"id":7721,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/posts\/3044\/revisions\/7721"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/media\/3045"}],"wp:attachment":[{"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/media?parent=3044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/categories?post=3044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecodest.co\/it\/wp-json\/wp\/v2\/tags?post=3044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}