{"id":9673,"date":"2021-10-09T11:43:58","date_gmt":"2021-10-09T11:43:58","guid":{"rendered":"https:\/\/exceptionly.com\/?p=9673"},"modified":"2022-06-29T16:40:25","modified_gmt":"2022-06-29T16:40:25","slug":"concurrency-and-multithreading-in-java","status":"publish","type":"post","link":"https:\/\/exceptionly.com\/ar\/2021\/10\/09\/concurrency-and-multithreading-in-java\/","title":{"rendered":"Concurrency and Multithreading in Java"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"9673\" class=\"elementor elementor-9673\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ed348b1 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ed348b1\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e660652\" data-id=\"e660652\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e63805d elementor-widget elementor-widget-text-editor\" data-id=\"e63805d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Imagine a coffee shop with only one employee, a cashier who is supposed to do all the work alone. Gets an order, makes the coffee, delivers it to the customer, and repeats.. which may take forever without concurrency.\u00a0<\/p><p>But having one more employee as a barista would really help, right? The cashier would gather orders and pass them to the barista, so once the barista was preparing an order, the cashier could get other orders, and the customers would not have to wait there all the time. The coffee shop would sell more coffee eventually.<\/p><p>What you see in coffee shops, restaurants is all about concurrency. Split and execute tasks simultaneously in a way that will not affect the outcome.\u00a0<\/p><p>In the above example;<\/p><ul><li>Process: Coffee Shop<\/li><li>Outcome:\u00a0 Coffee<\/li><li>Throughput:\u00a0 The number of coffee you can make in a period of time<\/li><li>Single thread: One person doing all the work in a certain order<\/li><li>Multi-thread: There are different people to achieve different tasks such as barista and cashier<\/li><\/ul><h2>What is concurrency?<\/h2><p>Concurrency is the ability to execute multiple tasks simultaneously without a certain order and achieve this by providing the same outcome.\u00a0<\/p><h2>Synchronization<\/h2><p>Synchronization is the ability to coordinate access of multiple threads to a shared resource. Synchronization in Java guarantees that only one thread can access a shared resource at any time.\u00a0<\/p><h2>Process vs. Threads<\/h2><p>Processes and threads are two basic execution units; while process refers to a Java Virtual Machine execution instance, the threads are a subset of the process.\u00a0<\/p><p>A Java Virtual Machine starts with a single thread by default which is called the main thread. And additional threads can be created by either;<\/p><ol><li>Implementing the Runnable interface<\/li><li aria-level=\"1\">implementing the Callable interface.<\/li><li aria-level=\"1\">Extending the Thread class\u00a0<\/li><\/ol><h3>Implementing the Runnable Interface for Concurrent Programming<\/h3><p><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/Runnable.html\">Oracle Java docs<\/a> specify the Runnable Interface as \u201cThe Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run.\u201d The Runnable Interface comes from Standart Java.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-78013e8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"78013e8\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7218683\" data-id=\"7218683\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1e10002 elementor-widget elementor-widget-code-highlight\" data-id=\"1e10002\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>public class TaskRunnable implements Runnable {\n @Override\n public void run() {\n   System.out.println(\"Thread name: \" +Thread.currentThread().getName());\n }\n}\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-594fb10 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"594fb10\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-150c7f6\" data-id=\"150c7f6\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d335373 elementor-widget elementor-widget-text-editor\" data-id=\"d335373\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>There are various ways that you can assign a Runnable task to a new thread.<\/p><h4>Execute a Runnable task by creating new Threads<\/h4><p>You can create a new thread from the constructor by passing the Runnable implementation. Please keep in mind that to spawn up a thread in parallel, you need to call the thread&#8217;s start method. If you end up calling the run method instead, it will run your Runnable task in the main thread with a certain order (sequentially).\u00a0<\/p><h5>Java Thread start() Method.<\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2c274d3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2c274d3\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d8568f7\" data-id=\"d8568f7\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-230f35a elementor-widget elementor-widget-code-highlight\" data-id=\"230f35a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>   for (int i = 0; i < 5; i++) {\n     Thread thread = new Thread(new TaskRunnable());\n     thread.start();\n   }\n }\n \n\/\/ Output \nThread name: Thread-3\nThread name: Thread-2\nThread name: Thread-4\nThread name: Thread-1\nThread name: Thread-0\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5612727 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5612727\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8f1dc2d\" data-id=\"8f1dc2d\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3a3fc9c elementor-widget elementor-widget-text-editor\" data-id=\"3a3fc9c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5>Java Thread run() Method<\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b593460 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b593460\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5074adb\" data-id=\"5074adb\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b52828a elementor-widget elementor-widget-code-highlight\" data-id=\"b52828a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp> for (int i = 0; i < 3; i++) {\n     Thread thread = new Thread(new TaskRunnable());\n     thread.run();\n   }\n\n\/\/Output\nThread name: main\nThread name: main\nThread name: main\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1c7e085 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1c7e085\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8f0cc0f\" data-id=\"8f0cc0f\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9348460 elementor-widget elementor-widget-text-editor\" data-id=\"9348460\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4>Execute a Runnable task with ExecutorService asynchronously<\/h4><p>The ExecutorService feature is released with Java 5 that allows you to run tasks asynchronously. With ExecutorService, you don&#8217;t need to create new threads each time but can use the already created threads from the pool.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4c0ee5a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4c0ee5a\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-47bf7f0\" data-id=\"47bf7f0\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4deb048 elementor-widget elementor-widget-code-highlight\" data-id=\"4deb048\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>ExecutorService executor = Executors.newFixedThreadPool(3);\nfor (int i = 0; i < 5; i++) {\n executor.submit(new TaskRunnable());\n}\n\n\/\/Output\nThread name: pool-1-thread-2\nThread name: pool-1-thread-3\nThread name: pool-1-thread-1\nThread name: pool-1-thread-3\nThread name: pool-1-thread-1\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f4bda78 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"f4bda78\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-193c393\" data-id=\"193c393\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7314833 elementor-widget elementor-widget-text-editor\" data-id=\"7314833\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4>Execute a Runnable Task with ExecutorService in a Lambda Expression<\/h4><p>Runnable is considered a functional interface as it has only one abstract method. This allows us to run a task in lambda expression without bothering to implement the Runnable interface separately.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5f0e394 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5f0e394\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5e6395c\" data-id=\"5e6395c\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f59a57e elementor-widget elementor-widget-code-highlight\" data-id=\"f59a57e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>ExecutorService executor = Executors.newFixedThreadPool(3);\nfor (int i = 0; i < 3; i++) {\n executor.submit(() -> System.out.println(\"Thread name: \" + Thread.currentThread().getName()));\n}\n\n\/\/Output\nThread name: pool-1-thread-3\nThread name: pool-1-thread-1\nThread name: pool-1-thread-2\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5148cfb elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5148cfb\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1ceaafa\" data-id=\"1ceaafa\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fb009b6 elementor-widget elementor-widget-text-editor\" data-id=\"fb009b6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3>Implementing the Callable Interface with ExecutorService<\/h3><p>The Callable interface is released with Java 5 within the concurrency package.\u00a0<\/p><p>It looks pretty similar to the Runnable interface. But Callable interface uses Java generics that means you can return any type based on your needs and throw exceptions.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-84bc26c elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"84bc26c\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-98326fc\" data-id=\"98326fc\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6ba85ce elementor-widget elementor-widget-code-highlight\" data-id=\"6ba85ce\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>ExecutorService executorService =  Executors.newSingleThreadExecutor();\n\nint input = 20;\nCallable<Double> callableTask = () -> Math.log(input);\nDouble result = executorService.submit(callableTask).get();\nSystem.out.println(result);\n\n\/\/Output\n2.995732273553991<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-61996fd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"61996fd\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6783588\" data-id=\"6783588\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6213210 elementor-widget elementor-widget-text-editor\" data-id=\"6213210\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3>Extending Thread Class to Execute Tasks<\/h3><p>Most of the time, extending a raw Thread class is not preferred as it mixes up the duty of running a task with the implementation of the task. Additionally, you will not extend any class even if you require it, which is a lack of inheritance.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-08b78e7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"08b78e7\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0445a8d\" data-id=\"0445a8d\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-620748d elementor-widget elementor-widget-code-highlight\" data-id=\"620748d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-dark copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-java\">\n\t\t\t\t<code readonly=\"true\" class=\"language-java\">\n\t\t\t\t\t<xmp>public class TaskThread extends Thread {\n public void run() {\n   System.out.println(\"Thread name: \" + Thread.currentThread().getName());\n }\n}\n\nfor (int i = 0; i < 3; i++) {\n TaskThread taskThread = new TaskThread();\n taskThread.start();\n}\n\n\/\/Output\nThread name: Thread-1\nThread name: Thread-2\nThread name: Thread-0\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2147850 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2147850\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1152dd8\" data-id=\"1152dd8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9502674 elementor-widget elementor-widget-text-editor\" data-id=\"9502674\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2>Why Concurrency?<\/h2><p>Concurrent programming maximizes the throughput by using the current resources most efficiently. As a result, it reduces the response time and helps you better utilize the CPU.\u00a0<\/p><p>Even though concurrent programming techniques increase the performance, there are some concurrency problems listed below that you should be aware of;<\/p><h3>Race Conditions\u00a0<\/h3><p>A race condition occurs when multiple threads access shared data and write at the same time. As overlapped executions are manipulating the shared object, the outcome can be unpredictable and corrupted.\u00a0\u00a0<\/p><h3>Deadlocks<\/h3><p>In concurrent programming, a deadlock is when multiple processes share the same resource and wait for each other to take any action or release a lock.\u00a0<\/p><h3>Resource Starvation<\/h3><p>Resource Starvation is a situation where a thread is being denied to gain access to a shared resource for an indefinite period.\u00a0\u00a0<\/p><p>I have several posts about different concepts in Java and other programming languages.\u00a0You might enjoy some of my other posts \u200b\u200b<a href=\"https:\/\/exceptionly.com\/ar\/2021\/08\/01\/5-top-common-mistakes-every-beginner-java-programmer-makes\/\">5 Top Common Mistakes Every Beginner Java Programmer Makes<\/a>, <a href=\"https:\/\/exceptionly.com\/ar\/2021\/07\/07\/how-to-start-coding-java-in-60-minutes\/\">How to start coding Java<\/a> or <a href=\"https:\/\/exceptionly.com\/ar\/2021\/09\/04\/deployment-strategies-canary-vs-blue-green-deployments\/\">Canary vs. Blue-Green Deployments<\/a> published on Exceptionly Blog.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Imagine a coffee shop with only one employee, a cashier who is supposed to do all the work alone. Gets an order, makes the coffee, delivers it to the customer, and repeats.. which may take forever without concurrency.&nbsp; But having one more employee as a barista would really help, right? The cashier would gather orders [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":9810,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[206,129,125,127,130,89,126,128,131],"class_list":["post-9673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-backend","tag-callable-interface","tag-concurrency","tag-deadlocks","tag-executorservice","tag-java-tutorials","tag-multithreading","tag-runnable-interface","tag-synchronization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.5 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Concurrency and Multithreading in Java - Exceptionly<\/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:\/\/exceptionly.com\/ar\/2021\/10\/09\/concurrency-and-multithreading-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"ar_AR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Concurrency and Multithreading in Java\" \/>\n<meta property=\"og:description\" content=\"Imagine a coffee shop with only one employee, a cashier who is supposed to do all the work alone. Gets an order, makes the coffee, delivers it to the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceptionly.com\/ar\/2021\/10\/09\/concurrency-and-multithreading-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Exceptionly\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/exceptionly\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-09T11:43:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-29T16:40:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1930\" \/>\n\t<meta property=\"og:image:height\" content=\"766\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fatma Elverir\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@exceptionly\" \/>\n<meta name=\"twitter:site\" content=\"@exceptionly\" \/>\n<meta name=\"twitter:label1\" content=\"\u0643\u064f\u062a\u0628 \u0628\u0648\u0627\u0633\u0637\u0629\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatma Elverir\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u0648\u0642\u062a \u0627\u0644\u0642\u0631\u0627\u0621\u0629 \u0627\u0644\u0645\u064f\u0642\u062f\u0651\u0631\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u062f\u0642\u0627\u0626\u0642\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/\"},\"author\":{\"name\":\"Fatma Elverir\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#\\\/schema\\\/person\\\/a2600170dfb4513350affede916c0ccf\"},\"headline\":\"Concurrency and Multithreading in Java\",\"datePublished\":\"2021-10-09T11:43:58+00:00\",\"dateModified\":\"2022-06-29T16:40:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/\"},\"wordCount\":813,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/concurrency-and-multithreading-in-java.jpg\",\"keywords\":[\"Backend\",\"callable interface\",\"concurrency\",\"deadlocks\",\"ExecutorService\",\"Java Tutorials\",\"multithreading\",\"runnable interface\",\"synchronization\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"ar\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/\",\"url\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/\",\"name\":\"Concurrency and Multithreading in Java - Exceptionly\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/concurrency-and-multithreading-in-java.jpg\",\"datePublished\":\"2021-10-09T11:43:58+00:00\",\"dateModified\":\"2022-06-29T16:40:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#breadcrumb\"},\"inLanguage\":\"ar\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ar\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#primaryimage\",\"url\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/concurrency-and-multithreading-in-java.jpg\",\"contentUrl\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/concurrency-and-multithreading-in-java.jpg\",\"width\":1930,\"height\":766,\"caption\":\"Concurrency and Multithreading in Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/2021\\\/10\\\/09\\\/concurrency-and-multithreading-in-java\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/exceptionly.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Concurrency and Multithreading in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#website\",\"url\":\"https:\\\/\\\/exceptionly.com\\\/\",\"name\":\"Exceptionly\",\"description\":\"Remote software talent acquisition at scale\",\"publisher\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/exceptionly.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ar\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#organization\",\"name\":\"Exceptionly\",\"url\":\"https:\\\/\\\/exceptionly.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ar\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/exceptionly-search-logo.png\",\"contentUrl\":\"https:\\\/\\\/exceptionly.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/exceptionly-search-logo.png\",\"width\":400,\"height\":400,\"caption\":\"Exceptionly\"},\"image\":{\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/exceptionly\\\/\",\"https:\\\/\\\/x.com\\\/exceptionly\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/exceptionly\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCet5wATTyif6knI0h4vUkNA\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/exceptionly.com\\\/#\\\/schema\\\/person\\\/a2600170dfb4513350affede916c0ccf\",\"name\":\"Fatma Elverir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ar\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g\",\"caption\":\"Fatma Elverir\"},\"sameAs\":[\"https:\\\/\\\/exceptionly.com\"],\"url\":\"https:\\\/\\\/exceptionly.com\\\/ar\\\/author\\\/fatmaelverir\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Concurrency and Multithreading in Java - Exceptionly","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:\/\/exceptionly.com\/ar\/2021\/10\/09\/concurrency-and-multithreading-in-java\/","og_locale":"ar_AR","og_type":"article","og_title":"Concurrency and Multithreading in Java","og_description":"Imagine a coffee shop with only one employee, a cashier who is supposed to do all the work alone. Gets an order, makes the coffee, delivers it to the","og_url":"https:\/\/exceptionly.com\/ar\/2021\/10\/09\/concurrency-and-multithreading-in-java\/","og_site_name":"Exceptionly","article_publisher":"https:\/\/www.facebook.com\/exceptionly\/","article_published_time":"2021-10-09T11:43:58+00:00","article_modified_time":"2022-06-29T16:40:25+00:00","og_image":[{"width":1930,"height":766,"url":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg","type":"image\/jpeg"}],"author":"Fatma Elverir","twitter_card":"summary_large_image","twitter_creator":"@exceptionly","twitter_site":"@exceptionly","twitter_misc":{"\u0643\u064f\u062a\u0628 \u0628\u0648\u0627\u0633\u0637\u0629":"Fatma Elverir","\u0648\u0642\u062a \u0627\u0644\u0642\u0631\u0627\u0621\u0629 \u0627\u0644\u0645\u064f\u0642\u062f\u0651\u0631":"5 \u062f\u0642\u0627\u0626\u0642"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#article","isPartOf":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/"},"author":{"name":"Fatma Elverir","@id":"https:\/\/exceptionly.com\/#\/schema\/person\/a2600170dfb4513350affede916c0ccf"},"headline":"Concurrency and Multithreading in Java","datePublished":"2021-10-09T11:43:58+00:00","dateModified":"2022-06-29T16:40:25+00:00","mainEntityOfPage":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/"},"wordCount":813,"commentCount":1,"publisher":{"@id":"https:\/\/exceptionly.com\/#organization"},"image":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg","keywords":["Backend","callable interface","concurrency","deadlocks","ExecutorService","Java Tutorials","multithreading","runnable interface","synchronization"],"articleSection":["Tutorials"],"inLanguage":"ar","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/","url":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/","name":"Concurrency and Multithreading in Java - Exceptionly","isPartOf":{"@id":"https:\/\/exceptionly.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#primaryimage"},"image":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg","datePublished":"2021-10-09T11:43:58+00:00","dateModified":"2022-06-29T16:40:25+00:00","breadcrumb":{"@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#breadcrumb"},"inLanguage":"ar","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"ar","@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#primaryimage","url":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg","contentUrl":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/10\/concurrency-and-multithreading-in-java.jpg","width":1930,"height":766,"caption":"Concurrency and Multithreading in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/exceptionly.com\/2021\/10\/09\/concurrency-and-multithreading-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/exceptionly.com\/"},{"@type":"ListItem","position":2,"name":"Concurrency and Multithreading in Java"}]},{"@type":"WebSite","@id":"https:\/\/exceptionly.com\/#website","url":"https:\/\/exceptionly.com\/","name":"Exceptionly","description":"Remote software talent acquisition at scale","publisher":{"@id":"https:\/\/exceptionly.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/exceptionly.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ar"},{"@type":"Organization","@id":"https:\/\/exceptionly.com\/#organization","name":"Exceptionly","url":"https:\/\/exceptionly.com\/","logo":{"@type":"ImageObject","inLanguage":"ar","@id":"https:\/\/exceptionly.com\/#\/schema\/logo\/image\/","url":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/05\/exceptionly-search-logo.png","contentUrl":"https:\/\/exceptionly.com\/wp-content\/uploads\/2021\/05\/exceptionly-search-logo.png","width":400,"height":400,"caption":"Exceptionly"},"image":{"@id":"https:\/\/exceptionly.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/exceptionly\/","https:\/\/x.com\/exceptionly","https:\/\/www.linkedin.com\/company\/exceptionly\/","https:\/\/www.youtube.com\/channel\/UCet5wATTyif6knI0h4vUkNA"]},{"@type":"Person","@id":"https:\/\/exceptionly.com\/#\/schema\/person\/a2600170dfb4513350affede916c0ccf","name":"Fatma Elverir","image":{"@type":"ImageObject","inLanguage":"ar","@id":"https:\/\/secure.gravatar.com\/avatar\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/93179e5b3e943c5bcda6ea20d6b37723c01dedb150ab7724bb4fb9af22eb3de6?s=96&d=mm&r=g","caption":"Fatma Elverir"},"sameAs":["https:\/\/exceptionly.com"],"url":"https:\/\/exceptionly.com\/ar\/author\/fatmaelverir\/"}]}},"_links":{"self":[{"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/posts\/9673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/comments?post=9673"}],"version-history":[{"count":0,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/posts\/9673\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/media\/9810"}],"wp:attachment":[{"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/media?parent=9673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/categories?post=9673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/exceptionly.com\/ar\/wp-json\/wp\/v2\/tags?post=9673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}