{"id":998,"date":"2022-07-03T12:11:13","date_gmt":"2022-07-03T10:11:13","guid":{"rendered":"https:\/\/ondro.inginea.eu\/?p=998"},"modified":"2023-03-18T12:01:01","modified_gmt":"2023-03-18T11:01:01","slug":"introduction-to-concurrency-and-threads-in-java-web-apps","status":"publish","type":"post","link":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/","title":{"rendered":"Introduction to concurrency and threads in Java web apps"},"content":{"rendered":"\n<p>Threads, concurrency, or synchronization are not very easy to understand concepts. When some concurrency is involved in our applications it&#8217;s pretty hard to avoid making mistakes. Although Java provides mechanisms to deal with parallel programming, sometimes there are just too many options. And often some essential options are missing. For web applications, Jakarta EE provides a simplified programming model to deal with parallel tasks. But in order to use it effectively and avoid mistakes, you need to understand the basic concepts which I&#8217;d like to explain here.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Java provides a lot of mechanisms to help working with threads and concurrent tasks. As Java evolved, some new mechanisms were added while old mechanisms stayed. And it&#8217;s often not clear which of them are better and recommended to use in new applications. Jakarta EE builds on these features and makes them easier to understand and use. The standard Jakarta EE API intentionally specifies only interfaces and essential conceptual behavior. A lot of the complexity is abstracted away and provided by Jakarta EE runtimes to keep things simple. As a result, developers have a concise set of features. Easy to learn and understand but enough to build applications.<\/p>\n\n\n\n<div class=\"wp-block-group omnifish-advert has-white-color has-text-color has-background\" style=\"background-color:#0b8f9b\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-color has-text-color\" style=\"grid-template-columns:auto 15%\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-medium-font-size\"><a rel=\"noreferrer noopener\" href=\"https:\/\/omnifish.ee\" data-type=\"URL\" data-id=\"https:\/\/omnifish.ee\" target=\"_blank\"><strong>Need help with GlassFish, Jakarta\u00a0EE, Java in the cloud?<\/strong><\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/omnifish.ee\" data-type=\"URL\" data-id=\"https:\/\/omnifish.ee\" target=\"_blank\">Follow me at <strong>OmniFish<\/strong>! <\/a><\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><a href=\"https:\/\/omnifish.ee\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"178\" data-attachment-id=\"1034\" data-permalink=\"https:\/\/ondro.inginea.eu\/omnifish-logo-transparent-400px\/\" data-orig-file=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?fit=400%2C237&amp;ssl=1\" data-orig-size=\"400,237\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"omnifish-logo-transparent-400px\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?fit=300%2C178&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?fit=400%2C237&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?resize=300%2C178&#038;ssl=1\" alt=\"\" class=\"wp-image-1034 size-medium\" srcset=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?resize=300%2C178&amp;ssl=1 300w, https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2022\/07\/omnifish-logo-transparent-400px.png?w=400&amp;ssl=1 400w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/a><\/figure><\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What is a thread pool<\/h2>\n\n\n\n<p>The basic concept of threading and parallelism in Jakarta EE runtimes is a <strong>thread pool<\/strong>. This is connected with the request processing model, where most of the tasks originate as a <strong>request from an external caller<\/strong>, they are then processed sequentially in a <strong>single thread<\/strong>, and produce some <strong>response<\/strong> that is usually sent back to the caller, persisted into a database or sent as a message to another system. Many separate tasks can run in parallel, each using its own separate thread. So there&#8217;s usually a simple mapping &#8211; one request needs one thread. After a task is finished, a thread doesn&#8217;t have to be destroyed. It can be reused to run another task, in order to avoid creating and destroying threads too often.<\/p>\n\n\n\n<p>Incoming tasks are not tied with any specific thread. A thread pool always makes sure there&#8217;s a thread available for a task. This is called &#8220;scheduling&#8221; and is often referred to as &#8220;thread scheduling&#8221;. Tasks are scheduled and processed either:<\/p>\n\n\n\n<p>by an existing thread that is finished with its previous task<\/p>\n\n\n\n<p>by a new thread if no free thread is available<\/p>\n\n\n\n<p>or they are queued and wait until a thread is available if all threads are busy<\/p>\n\n\n\n<p>Vice versa, threads aren&#8217;t tied to tasks either. They just take a task from a queue and process it. When threads are done with their tasks, they start processing another new task from a queue or wait for a task if the queue is empty. A group of such threads, together with the logic how they are managed and scheduled, is called a thread pool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why thread pools?<\/h2>\n\n\n\n<p>Thread pools are used because it&#8217;s time-consuming to dispose a thread and create a new thread later. A new thread is created only when there&#8217;s no idle thread already available. And they are disposed only when there are already too many idle threads it&#8217;s likely not going to be needed for some time.<\/p>\n\n\n\n<p>Another aspect of thread pools is that their size is limited and adapts to the load. This is mainly for 3 reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Threads allocates some memory for their stacks and keep the memory until the threads are disposed<\/li>\n\n\n\n<li>The CPU can run very small number of threads at once; having too many threads can even lead to performance degradation<\/li>\n\n\n\n<li>Each task requires some heap memory; it makes sense to limit the maximum number of parallel tasks to avoid overwhelming the system<\/li>\n<\/ul>\n\n\n\n<p>The memory argument is pretty clear and often it&#8217;s evident when it becomes and issue. There&#8217;s always a limited amount of memory on the system. When threads consume a big portion of that memory, it&#8217;s easy to reach the limit. The default stack size for each thread is 1MB, which means that each thread needs 1MB of system memory. If there are 1000 threads in a JVM, they clearly need 1GB of memory on top of the Java heap size just to exist. You can probably imagine the consequences if there are even more threads. <\/p>\n\n\n\n<p>The CPU argument isn&#8217;t so straightforward but is really valid. Only X amount of threads can run on a CPU at the same time (usually 8 on an 8-core CPU). With more threads, it&#8217;s more likely that a thread will be suspended and another thread will be scheduled. Switching of threads is a relatively time-consuming operation and doesn&#8217;t contribute to the computation. Therefore, having an excessive amount of threads can actually decrease performance.<\/p>\n\n\n\n<p>The last argument is that executing too many tasks in parallel costs too much memory as each tasks needs to store something to the heap even if it&#8217;s waiting for an I\/O operation or the CPU. As described above, more parallel tasks doesn&#8217;t not always lead to increased performance. But it definitely leads to increased memory. Therefore it&#8217;s better to limit how many tasks can run in parallel and queue other tasks to be executed later.<\/p>\n\n\n\n<p>For these reasons, it&#8217;s good to have some reasonable amount of threads ready to handle new tasks immediately. It&#8217;s also necessary to limit the number of threads to a reasonable amount. And threads should also be disposed after some time if they are really not needed. With this, it&#8217;s possible to avoid system become thrashed and unusable under high load.  If there are too many requests to handle, some of them simply need to wait while others can be efficiently processed. This will make the system usable at least for some requests\/users.<\/p>\n\n\n\n<p>Sometimes a single request needs to be processed by multiple threads in parallel. This doesn&#8217;t fit the simplified thread-per-request model but it&#8217;s also supported by Jakarta EE runtimes. Applications can use a specialized <a href=\"https:\/\/jakarta.ee\/specifications\/concurrency\/\" target=\"_blank\" rel=\"noreferrer noopener\">concurrency API<\/a>, which allows splitting a task and execute each part in a separate thread. This again works on top of thread pools to retain all the advantages mentioned above. <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Threads, concurrency, or synchronization are not very easy to understand concepts. Jakarta EE builds on standard Java features and makes them easier to understand and use, using the thread pool concept and the Jakarta Concurrency API.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[192],"tags":[235,233,83],"series":[],"class_list":["post-998","post","type-post","status-publish","format-standard","hentry","category-jakarta-ee","tag-concurrency-en","tag-jakartaee-en","tag-javaee-en"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Introduction to concurrency and threads in Java web apps - .Lost in Coding<\/title>\n<meta name=\"description\" content=\"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to concurrency and threads in Java web apps - .Lost in Coding\" \/>\n<meta property=\"og:description\" content=\"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\" \/>\n<meta property=\"og:site_name\" content=\".Lost in Coding\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ondrej.mihalyi\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-03T10:11:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-18T11:01:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"202\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ondro Mih\u00e1lyi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OndroMih\" \/>\n<meta name=\"twitter:site\" content=\"@OndroMih\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ondro Mih\u00e1lyi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\"},\"author\":{\"name\":\"Ondro Mih\u00e1lyi\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"headline\":\"Introduction to concurrency and threads in Java web apps\",\"datePublished\":\"2022-07-03T10:11:13+00:00\",\"dateModified\":\"2023-03-18T11:01:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\"},\"wordCount\":1034,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"keywords\":[\"concurrency\",\"jakartaee\",\"javaee\"],\"articleSection\":[\"Jakarta EE\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\",\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\",\"name\":\"Introduction to concurrency and threads in Java web apps - .Lost in Coding\",\"isPartOf\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#website\"},\"datePublished\":\"2022-07-03T10:11:13+00:00\",\"dateModified\":\"2023-03-18T11:01:01+00:00\",\"description\":\"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.\",\"breadcrumb\":{\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ondro.inginea.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introduction to concurrency and threads in Java web apps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ondro.inginea.eu\/#website\",\"url\":\"https:\/\/ondro.inginea.eu\/\",\"name\":\".Lost in Coding\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ondro.inginea.eu\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616\",\"name\":\"Ondro Mih\u00e1lyi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"contentUrl\":\"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1\",\"width\":300,\"height\":300,\"caption\":\"Ondro Mih\u00e1lyi\"},\"logo\":{\"@id\":\"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/\"},\"description\":\"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)\",\"sameAs\":[\"https:\/\/www.facebook.com\/ondrej.mihalyi\",\"https:\/\/cz.linkedin.com\/in\/mihalyiondrej\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih\"],\"url\":\"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to concurrency and threads in Java web apps - .Lost in Coding","description":"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.","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:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/","og_locale":"en_US","og_type":"article","og_title":"Introduction to concurrency and threads in Java web apps - .Lost in Coding","og_description":"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.","og_url":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/","og_site_name":".Lost in Coding","article_publisher":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_author":"https:\/\/www.facebook.com\/ondrej.mihalyi","article_published_time":"2022-07-03T10:11:13+00:00","article_modified_time":"2023-03-18T11:01:01+00:00","og_image":[{"width":300,"height":202,"url":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1","type":"image\/png"}],"author":"Ondro Mih\u00e1lyi","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OndroMih","twitter_site":"@OndroMih","twitter_misc":{"Written by":"Ondro Mih\u00e1lyi","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#article","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/"},"author":{"name":"Ondro Mih\u00e1lyi","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"headline":"Introduction to concurrency and threads in Java web apps","datePublished":"2022-07-03T10:11:13+00:00","dateModified":"2023-03-18T11:01:01+00:00","mainEntityOfPage":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/"},"wordCount":1034,"commentCount":0,"publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"keywords":["concurrency","jakartaee","javaee"],"articleSection":["Jakarta EE"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/","url":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/","name":"Introduction to concurrency and threads in Java web apps - .Lost in Coding","isPartOf":{"@id":"https:\/\/ondro.inginea.eu\/#website"},"datePublished":"2022-07-03T10:11:13+00:00","dateModified":"2023-03-18T11:01:01+00:00","description":"Jakarta EE uses the thread pool concept and the Jakarta Concurrency API to make threading and concurrency concepts easier to understand and use.","breadcrumb":{"@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ondro.inginea.eu\/index.php\/introduction-to-concurrency-and-threads-in-java-web-apps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ondro.inginea.eu\/"},{"@type":"ListItem","position":2,"name":"Introduction to concurrency and threads in Java web apps"}]},{"@type":"WebSite","@id":"https:\/\/ondro.inginea.eu\/#website","url":"https:\/\/ondro.inginea.eu\/","name":".Lost in Coding","description":"","publisher":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ondro.inginea.eu\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/07ac1158ec74720744f7146572215616","name":"Ondro Mih\u00e1lyi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/","url":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","contentUrl":"https:\/\/i2.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/08\/fotoOMsquare3x300.jpg?fit=300%2C300&ssl=1","width":300,"height":300,"caption":"Ondro Mih\u00e1lyi"},"logo":{"@id":"https:\/\/ondro.inginea.eu\/#\/schema\/person\/image\/"},"description":"Ondro is a software developer and consultant specializing in combining standard and proven tools to solve new and challenging problems. He's been developing in Java for over 10 years. He\u2019s worked for clients like Payara, LottoLand, Uniqa and others. He has co-founded OmniFish, where he works as a director and Jakarta EE expert. He\u2019s passionate about helping his clients and the wider Java community with their projects based on Jakarta EE and similar technologies. As an experienced Java developer and instructor, he's helped companies build and educate their development teams and improve their development processes. He's a core member of several opensource projects and Jakarta EE specification projects. He\u2019s a frequent conference speaker, leader of the Czech JUG and a Java Champion. Ondro is a regular conference speaker at international conferences. Since 2016, he's presented at the following conferences: \u2022 FOSDEM, Brussels, Belgium 2023) \u2022 JChampionsConf, Online (year 2023) \u2022 EclipseCon, Germany (year 2022) \u2022 GeeCon, Prague, Czechia (years 2016, 2019, 2022) \u2022 JavaLand, Bruehl, Germany (years 2018, 2021) \u2022 JFokus, Stockholm, Sweden (year 2019) \u2022 Devops Con, Munich, Germany (year 2019) \u2022 Oracle CodeOne, San Francisco, USA (years 2018, 2019) \u2022 Devoxx, Antwerp, Belgium (year 2018) \u2022 JPrime, Sofia, Bulgaria (years 2017, 2018) \u2022 Java2Days, Sofia, Bulgaria (years 2016, 2018) \u2022 EclipseCon, France (year 2018) \u2022 JavaOne, San Francisco, USA (years 2016, 2017) \u2022 Oracle Code, Prague, Czechia (year 2017) \u2022 Devoxx, London, UK (year 2017) \u2022 GeeCon, Krakow, Poland (year 2017) \u2022 W-JAX, Munich, Germany (years 2016, 2017) \u2022 Bed-Con, Berlin, Germany (year 2017) \u2022 Oredev, Malmo, Sweden (year 2017) \u2022 Devoxx, Casablanca, Morocco (year 2017) \u2022 Java Developer Days, Krakow, Poland (year 2016)","sameAs":["https:\/\/www.facebook.com\/ondrej.mihalyi","https:\/\/cz.linkedin.com\/in\/mihalyiondrej","https:\/\/twitter.com\/https:\/\/twitter.com\/OndroMih"],"url":"https:\/\/ondro.inginea.eu\/index.php\/author\/ondrejm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6wlb6-g6","jetpack-related-posts":[{"id":877,"url":"https:\/\/ondro.inginea.eu\/index.php\/jakarta-ee-experts-at-eclipsecon-2021\/","url_meta":{"origin":998,"position":0},"title":"Jakarta EE experts at EclipseCon 2021","author":"Ondro Mih\u00e1lyi","date":"23 August, 2021","format":false,"excerpt":"EclipseCon conference is a great event for all Java developers, especially those who are passionate about and believe in opensource. The conference is scheduled for 26-28 October 2021. I wholeheartedly recommend to attend it. It's a free online event, you just need to register to attend: https:\/\/www.eclipsecon.org\/2021 Specifically for users\u2026","rel":"","context":"In &quot;Events &amp; Conferences&quot;","block_context":{"text":"Events &amp; Conferences","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/events-conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":769,"url":"https:\/\/ondro.inginea.eu\/index.php\/new-features-in-java-versions-since-java-8\/","url_meta":{"origin":998,"position":1},"title":"New features between Java 8 and Java 19","author":"Ondro Mih\u00e1lyi","date":"8 October, 2022","format":false,"excerpt":"Since version 9, Java has new features every 6 months and it's very hard to keep track of these new changes. Most of the information on the internet describes changes between the last 2 Java versions. However, if you're in a similar situation as me, you're not using one of\u2026","rel":"","context":"In &quot;Java&quot;","block_context":{"text":"Java","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2021\/09\/duke-CloudSurf-small-e1637277171314.png?fit=300%2C202&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":286,"url":"https:\/\/ondro.inginea.eu\/index.php\/building-a-new-productive-team-around-java-ee-7\/","url_meta":{"origin":998,"position":2},"title":"Building a new productive team around Java&nbsp;EE&nbsp;7","author":"Ondro Mih\u00e1lyi","date":"18 April, 2016","format":false,"excerpt":"Anton Smutn\u00fd is a software engineering manager at Muehlbauer Group, an international industrial company specializing in wide array of technologies. At the technology center located in Nitra, Slovakia, they are building a new agile Java team to fulfil growing internal needs for innovation and automation. Their team approached me to\u2026","rel":"","context":"In &quot;Interviews&quot;","block_context":{"text":"Interviews","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/interviews\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":157,"url":"https:\/\/ondro.inginea.eu\/index.php\/structure-of-modern-java-ee-application-in-slovak-language\/","url_meta":{"origin":998,"position":3},"title":"[Slovak language] \u0160trukt\u00fara modernej Java EE aplik\u00e1cie","author":"Ondro Mih\u00e1lyi","date":"4 October, 2015","format":false,"excerpt":"Read in Slovak language: \u0160trukt\u00fara modernej Java EE aplik\u00e1cie (Structure of modern Java EE application). \u00a0","rel":"","context":"In &quot;Slovak&quot;","block_context":{"text":"Slovak","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/slovak\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":209,"url":"https:\/\/ondro.inginea.eu\/index.php\/mvc-1-0-in-java-ee-8-getting-started-using-facelets\/","url_meta":{"origin":998,"position":4},"title":"MVC 1.0 in Java EE 8: Getting started using facelets","author":"Ondro Mih\u00e1lyi","date":"19 January, 2016","format":false,"excerpt":"MVC 1.0 is an action-based Model-View-Controller web framework, which will be a part of future Java EE 8. It will live side by side with component-based JSF framework and will provide an alternative for building HTML+javascript oriented applications with full control over URLs. This post summarizes what needs to be\u2026","rel":"","context":"In &quot;Jakarta EE&quot;","block_context":{"text":"Jakarta EE","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/java\/jakarta-ee\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":533,"url":"https:\/\/ondro.inginea.eu\/index.php\/using-hotswapagent-to-speed-up-development\/","url_meta":{"origin":998,"position":5},"title":"Using HotswapAgent to speed up development","author":"Ondro Mih\u00e1lyi","date":"20 October, 2017","format":false,"excerpt":"As a Java EE developer, I sometimes envy how fast it's possible to see the result of a code change in a running application with interpreted languages like PHP or JavaScript. With Java, it's always necessary to rebuild the source code in a bytecode, which can be then safely updated\u2026","rel":"","context":"In &quot;Configuration&quot;","block_context":{"text":"Configuration","link":"https:\/\/ondro.inginea.eu\/index.php\/category\/config\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/ondro.inginea.eu\/wp-content\/uploads\/2017\/09\/Screenshot-from-DCEVM.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/998"}],"collection":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/comments?post=998"}],"version-history":[{"count":10,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/998\/revisions"}],"predecessor-version":[{"id":1117,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/posts\/998\/revisions\/1117"}],"wp:attachment":[{"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/media?parent=998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/categories?post=998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/tags?post=998"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ondro.inginea.eu\/index.php\/wp-json\/wp\/v2\/series?post=998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}