{"id":3138,"date":"2022-06-15T05:27:58","date_gmt":"2022-06-15T05:27:58","guid":{"rendered":"http:\/\/the-codest.localhost\/blog\/concurrency-in-java-part-1-introduction\/"},"modified":"2026-03-11T05:59:41","modified_gmt":"2026-03-11T05:59:41","slug":"concurrency-in-java-part-1-introduction","status":"publish","type":"post","link":"https:\/\/thecodest.co\/en\/blog\/concurrency-in-java-part-1-introduction\/","title":{"rendered":"Concurrency in Java Part 1 &#8211; Introduction"},"content":{"rendered":"\n<p>In general, the conventional programming approach is sequential. Everything in a program happens one step at a time.<br>But, in fact, the parallel is how the whole world runs \u2013 it is the ability to execute more than one task simultaneously.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Thread vs. process<\/h2>\n\n\n\n<p>To discuss such advanced topics as <strong>concurrency in <a href=\"https:\/\/thecodest.co\/en\/blog\/top-programming-languages-to-build-e-commerce\/\">Java<\/a><\/strong> or multithreading, we have to settle on some common definitions to be sure we are on the same page.<\/p>\n\n\n\n<p>Let&#8217;s start with the basics. In the non-sequential world, we have two kinds of concurrency representants: processes and<br>threads. A process is an instance of the program running. Normally, it is isolated from other processes.<br>The operating system is responsible for assigning resources to each process. Moreover, it acts as a conductor that<br>schedules and controls them.<\/p>\n\n\n\n<p>Thread is a kind of a process but on a lower level, therefore it is also known as light thread. Multiple threads can run in one<br>process. Here the program acts as a scheduler and a controller for threads. This way individual programs appear to do<br>multiple tasks at the same time.<\/p>\n\n\n\n<p>The fundamental difference between threads and processes is the isolation level. The process has its own set of<br>resources, whereas the thread shares <a href=\"https:\/\/thecodest.co\/en\/blog\/app-data-collection-security-risks-value-and-types-explored\/\">data<\/a> with other threads. It may seem like an error-prone approach and indeed it is. For<br>now, let&#8217;s not focus on that as it&#8217;s beyond the scope of this article.<\/p>\n\n\n\n<p>Processes, threads &#8211; ok&#8230; But what exactly is concurrency? Concurrency means you can execute multiple tasks at the same<br>time. It does not mean those tasks have to run simultaneously \u2013 that&#8217;s what parallelism is. <strong>Concurrenc in Javay<\/strong> also does not<br>require you to have multiple CPUs or even multiple cores. It can be achieved in a single-core environment by leveraging<br>context switching.<\/p>\n\n\n\n<p>A term related to concurrency is multithreading. This is a feature of programs that allows them to execute several tasks at once. Not every program uses this approach but the ones that do can be called multithreaded.<\/p>\n\n\n\n<p>We are almost ready to go, just one more definition. Asynchrony means that a program performs non-blocking operations.<br>It initiates a task and then goes on with other things while waiting for the response. When it gets the response, it can <a href=\"https:\/\/thecodest.co\/en\/blog\/react-development-all-you-have-to-know\/\">react<\/a> to it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">All that jazz<\/h2>\n\n\n\n<p>By default, each <strong>Java application<\/strong> runs in one process. In that process, there is one thread related to the <code>main()<\/code> method of<br>an application. However, as mentioned, it is possible to leverage the mechanisms of multiple threads within one<br>program.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Runnable<\/h3>\n\n\n\n<p><code>Thread<\/code> is a <strong>Java<\/strong> class in which the magic happens. This is the object representation of the before mentioned thread. To<br>create your own thread, you can extend the <code>Thread<\/code> class. However, it is not a recommended approach. <code>Threads<\/code> should be used as a mechanism that run the task. Tasks are pieces of <a href=\"https:\/\/thecodest.co\/en\/dictionary\/what-is-code-refactoring\/\">code<\/a> that we want to run in a concurrent mode. We can define them using the <code>Runnable<\/code> interface.<\/p>\n\n\n\n<p>But enough theory, let&#8217;s put our code where our mouth is.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Problem<\/h3>\n\n\n\n<p>Assume we have a couple of arrays of numbers. For each array, we want to know the sum of the numbers in an array. Let&#8217;s<br>pretend there are a lot of such arrays and each of them is relatively big. In such conditions, we want to make use of concurrency and sum each array as a separate task.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\">int[] a1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\nint[] a2 = {10, 10, 10, 10, 10, 10, 10, 10};\nint[] a3 = {3, 4, 3, 4, 3, 4, 2, 1, 3, 7};\n\nRunnable task1 = () -&gt; {\n    int sum = Arrays.stream(a1).sum();\n    System.out.println(\"1. The sum is: \" + sum);\n};\n\nRunnable task2 = () -&gt; {\n    int sum = Arrays.stream(a2).sum();\n    System.out.println(\"2. The sum is: \" + sum);\n};\n\nRunnable task3 = () -&gt; {\n    int sum = Arrays.stream(a3).sum();\n    System.out.println(\"3. The sum is: \" + sum);\n};\n\nnew Thread(task1).start();\nnew Thread(task2).start();\nnew Thread(task3).start();<\/code><\/pre>\n\n\n\n<p>As you can see from the code above <code>Runnable<\/code> is a functional interface. It contains a single abstract method <code>run()<\/code><br>with no arguments. The <code>Runnable<\/code> interface should be implemented by any class whose instances are intended to be<br>executed by a thread.<\/p>\n\n\n\n<p>Once you have defined a task you can create a thread to run it. This can be achieved via <code>new Thread()<\/code> constructor that<br>takes <code>Runnable<\/code> as its argument.<\/p>\n\n\n\n<p>The final step is to <code>start()<\/code> a newly created thread. In the <a href=\"https:\/\/thecodest.co\/en\/blog\/compare-staff-augmentation-firms-that-excel-in-api-team-staffing-for-financial-technology-projects\/\">API<\/a> there are also <code>run()<\/code> methods in <code>Runnable<\/code> and in<br><code>Thread<\/code>. However, that is not a way to leverage concurrency in Java. A direct call to each of these methods results in<br>executing the task in the same thread the <code>main()<\/code> method runs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Thread pools and Executors<\/h3>\n\n\n\n<p>When there are a lot of tasks, creating a separate thread for each one is not a good idea. Creating a <code>Thread<\/code> is a<br>heavyweight operation and it&#8217;s far better to reuse existing threads than to create new ones.<\/p>\n\n\n\n<p>When a program creates many short-lived threads it is better to use a thread pool. The thread pool contains a number of<br>ready-to-run but currently not active threads. Giving a <code>Runnable<\/code> to the pool causes one of the threads calls the<br><code>run()<\/code> method of given <code>Runnable<\/code>. After completing a task the thread still exists and is in an idle state.<\/p>\n\n\n\n<p>Ok, you get it &#8211; prefer thread pool instead of manual creation. But how can you make use of thread pools? The <code>Executors<\/code><br>class has a number of static factory methods for constructing thread pools. For example <code>newCachedThredPool()<\/code> creates<br>a pool in which new threads are created as needed and idle threads are kept for 60 seconds. In contrast,<br><code>newFixedThreadPool()<\/code> contains a fixed set of threads, in which idle threads are kept indefinitely.<\/p>\n\n\n\n<p>Let&#8217;s see how it could work in our example. Now we do not need to create threads manually. Instead, we have to create<br><code>ExecutorService<\/code> which provides a pool of threads. Then we can assign tasks to it. The last step is to close the thread<br>pool to avoid memory leaks. The rest of the previous code stays the same.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\">ExecutorService executor = Executors.newCachedThreadPool();\n\nexecutor.submit(task1);\nexecutor.submit(task2);\nexecutor.submit(task3);\n\nexecutor.shutdown();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Callable<\/h3>\n\n\n\n<p><code>Runnable<\/code> seems like a nifty way of creating concurrent tasks but it has one major shortcoming. It cannot return any<br>value. What is more, we cannot determine if a task is finished or not. We also do not know if it has been completed<br>normally or exceptionally. The solution to those ills is <code>Callable<\/code>.<\/p>\n\n\n\n<p><code>Callable<\/code> is similar to <code>Runnable<\/code> in a way it also wraps asynchronous tasks. The main difference is it is able to<br>return a value. The return value can be of any (non-primitive) type as the <code>Callable<\/code> interface is a parameterized type.<br><code>Callable<\/code> is a functional interface that has <code>call()<\/code> method which can throw an <code>Exception<\/code>.<\/p>\n\n\n\n<p>Now let&#8217;s see how we can leverage <code>Callable<\/code> in our array problem.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\">int[] a1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\nint[] a2 = {10, 10, 10, 10, 10, 10, 10, 10};\nint[] a3 = {3, 4, 3, 4, 3, 4, 2, 1, 3, 7};\n\nCallable&lt;Integer&gt; task1 = () -&gt; Arrays.stream(a1).sum();\nCallable&lt;Integer&gt; task2 = () -&gt; Arrays.stream(a2).sum();\nCallable&lt;Integer&gt; task3 = () -&gt; Arrays.stream(a3).sum();\n\nExecutorService executor = Executors.newCachedThreadPool();\nFuture&lt;Integer&gt; future1 = executor.submit(task1);\nFuture&lt;Integer&gt; future2 = executor.submit(task2);\nFuture&lt;Integer&gt; future3 = executor.submit(task3);\n\nSystem.out.println(\"1. The sum is: \" + future1.get());\nSystem.out.println(\"2. The sum is: \" + future2.get());\nSystem.out.println(\"3. The sum is: \" + future3.get());\n\nexecutor.shutdown();<\/code><\/pre>\n\n\n\n<p>Okay, we can see how <code>Callable<\/code> is created and then submitted to <code>ExecutorService<\/code>. But what the heck is <code>Future<\/code>?<br><code>Future<\/code> acts as a bridge between threads. The sum of each array is produced in a separate thread and we need a way to<br>get those results back to <code>main()<\/code>.<\/p>\n\n\n\n<p>To retrieve the result from <code>Future<\/code> we need to call <code>get()<\/code> method. Here can one of two things happen. First, the<br>result of the computation performed by <code>Callable<\/code> is available. Then we get it immediately. Second, the result is not<br>ready yet. In that case <code>get()<\/code> method will block until the result is available.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ComputableFuture<\/h3>\n\n\n\n<p>The issue with <code>Future<\/code> is that it works in the &#8216;push paradigm&#8217;. When using <code>Future<\/code> you have to be like a boss who<br>constantly asks: &#8216;Is your task done? Is it ready?&#8217; until it provides a result. Acting under constant pressure is<br>expensive. Way better approach would be to order <code>Future<\/code> what to do when it is ready with its task. Unfortunately,<br><code>Future<\/code> cannot do that but <code>ComputableFuture<\/code> can.<\/p>\n\n\n\n<p><code>ComputableFuture<\/code> works in &#8216;pull paradigm&#8217;. We can tell it what to do with the result when it completed its tasks. It<br>is an example of an asynchronous approach.<\/p>\n\n\n\n<p><code>ComputableFuture<\/code> works perfectly with <code>Runnable<\/code> but not with <code>Callable<\/code>. Instead, it is possible to supply a task to<br><code>ComputableFuture<\/code> in form of <code>Supplier<\/code>.<\/p>\n\n\n\n<p>Let&#8217;s see how the above relates to our problem.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\">int[] a1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\nint[] a2 = {10, 10, 10, 10, 10, 10, 10, 10};\nint[] a3 = {3, 4, 3, 4, 3, 4, 2, 1, 3, 7};\n\nCompletableFuture.supplyAsync(() -&gt; Arrays.stream(a1).sum())\n                .thenAccept(System.out::println);\n\nCompletableFuture.supplyAsync(() -&gt; Arrays.stream(a2).sum())\n                .thenAccept(System.out::println);\n\nCompletableFuture.supplyAsync(() -&gt; Arrays.stream(a3).sum())\n                .thenAccept(System.out::println);<\/code><\/pre>\n\n\n\n<p>The first thing that strikes you is how much shorter this solution is. Besides that, it also looks neat and tidy.<\/p>\n\n\n\n<p>Task to <code>CompletableFuture<\/code> can be provided by <code>supplyAsync()<\/code> method that takes <code>Supplier<\/code> or by <code>runAsync()<\/code> that<br>takes <code>Runnable<\/code>. A callback &#8211; a piece of code that should be run on task completion &#8211; is defined by <code>thenAccept()<\/code><br>method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p><strong>Java<\/strong> provides a lot of different approaches to concurrency. In this article, we barely touched on the topic.<\/p>\n\n\n\n<p>Nevertheless, we covered the basics of <code>Thread<\/code>, <code>Runnable<\/code>, <code>Callable<\/code>, and <code>CallableFuture<\/code> which poses a good point<br>for farther topic investigation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/thecodest.co\/contact\/\"><img loading=\"lazy\" decoding=\"async\" width=\"1283\" height=\"460\" src=\"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_.png\" alt=\"\" class=\"wp-image-4927\" srcset=\"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_.png 1283w, https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_-300x108.png 300w, https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_-1024x367.png 1024w, https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_-768x275.png 768w, https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_-18x6.png 18w, https:\/\/thecodest.co\/app\/uploads\/2024\/05\/interested_in_cooperation_-67x24.png 67w\" sizes=\"auto, (max-width: 1283px) 100vw, 1283px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Read the first part of our blog series devoted to concurrency in Java. In the following article we will take a closer look at differences between thread and processes, thread pools, executors  and many more!<\/p>\n","protected":false},"author":2,"featured_media":3139,"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-3138","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>Concurrency in Java Part 1 - Introduction - The Codest<\/title>\n<meta name=\"description\" content=\"Read the first part of our blog series devoted to concurrency in Java.\" \/>\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\/en\/blog\/concurrency-in-java-part-1-introduction\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Concurrency in Java Part 1 - Introduction\" \/>\n<meta property=\"og:description\" content=\"Read the first part of our blog series devoted to concurrency in Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thecodest.co\/en\/blog\/concurrency-in-java-part-1-introduction\/\" \/>\n<meta property=\"og:site_name\" content=\"The Codest\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-15T05:27:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-11T05:59:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/\"},\"author\":{\"name\":\"thecodest\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/person\\\/7e3fe41dfa4f4e41a7baad4c6e0d4f76\"},\"headline\":\"Concurrency in Java Part 1 &#8211; Introduction\",\"datePublished\":\"2022-06-15T05:27:58+00:00\",\"dateModified\":\"2026-03-11T05:59:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/\"},\"wordCount\":1295,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/concurrency_in_java_part_1_-_introduction.png\",\"articleSection\":[\"Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/\",\"name\":\"Concurrency in Java Part 1 - Introduction - The Codest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/concurrency_in_java_part_1_-_introduction.png\",\"datePublished\":\"2022-06-15T05:27:58+00:00\",\"dateModified\":\"2026-03-11T05:59:41+00:00\",\"description\":\"Read the first part of our blog series devoted to concurrency in Java.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#primaryimage\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/concurrency_in_java_part_1_-_introduction.png\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/concurrency_in_java_part_1_-_introduction.png\",\"width\":960,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/concurrency-in-java-part-1-introduction\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thecodest.co\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Concurrency in Java Part 1 &#8211; Introduction\"}]},{\"@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\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\",\"name\":\"The Codest\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@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\":\"en-US\",\"@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\\\/en\\\/author\\\/thecodest\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Concurrency in Java Part 1 - Introduction - The Codest","description":"Read the first part of our blog series devoted to concurrency in Java.","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\/en\/blog\/concurrency-in-java-part-1-introduction\/","og_locale":"en_US","og_type":"article","og_title":"Concurrency in Java Part 1 - Introduction","og_description":"Read the first part of our blog series devoted to concurrency in Java.","og_url":"https:\/\/thecodest.co\/en\/blog\/concurrency-in-java-part-1-introduction\/","og_site_name":"The Codest","article_published_time":"2022-06-15T05:27:58+00:00","article_modified_time":"2026-03-11T05:59:41+00:00","og_image":[{"width":960,"height":540,"url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png","type":"image\/png"}],"author":"thecodest","twitter_card":"summary_large_image","twitter_misc":{"Written by":"thecodest","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#article","isPartOf":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/"},"author":{"name":"thecodest","@id":"https:\/\/thecodest.co\/#\/schema\/person\/7e3fe41dfa4f4e41a7baad4c6e0d4f76"},"headline":"Concurrency in Java Part 1 &#8211; Introduction","datePublished":"2022-06-15T05:27:58+00:00","dateModified":"2026-03-11T05:59:41+00:00","mainEntityOfPage":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/"},"wordCount":1295,"commentCount":0,"publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"image":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png","articleSection":["Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/","url":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/","name":"Concurrency in Java Part 1 - Introduction - The Codest","isPartOf":{"@id":"https:\/\/thecodest.co\/#website"},"primaryImageOfPage":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#primaryimage"},"image":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png","datePublished":"2022-06-15T05:27:58+00:00","dateModified":"2026-03-11T05:59:41+00:00","description":"Read the first part of our blog series devoted to concurrency in Java.","breadcrumb":{"@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#primaryimage","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/concurrency_in_java_part_1_-_introduction.png","width":960,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/thecodest.co\/blog\/concurrency-in-java-part-1-introduction\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thecodest.co\/"},{"@type":"ListItem","position":2,"name":"Concurrency in Java Part 1 &#8211; Introduction"}]},{"@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":"en-US"},{"@type":"Organization","@id":"https:\/\/thecodest.co\/#organization","name":"The Codest","url":"https:\/\/thecodest.co\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@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":"en-US","@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\/en\/author\/thecodest\/"}]}},"_links":{"self":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/comments?post=3138"}],"version-history":[{"count":8,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3138\/revisions"}],"predecessor-version":[{"id":8551,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3138\/revisions\/8551"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/media\/3139"}],"wp:attachment":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/media?parent=3138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/categories?post=3138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/tags?post=3138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}