<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ajay Kumar Namdev on Medium]]></title>
        <description><![CDATA[Stories by Ajay Kumar Namdev on Medium]]></description>
        <link>https://medium.com/@ajaykumarnamdev?source=rss-ac373ab5a519------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bJCNZ4s5gjqHP03A.</url>
            <title>Stories by Ajay Kumar Namdev on Medium</title>
            <link>https://medium.com/@ajaykumarnamdev?source=rss-ac373ab5a519------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:20:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajaykumarnamdev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Multithreading in Java — Thread Definition by javatechworld]]></title>
            <link>https://medium.com/@ajaykumarnamdev/multithreading-in-java-thread-definition-by-javatechworld-1d39481075a2?source=rss-ac373ab5a519------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d39481075a2</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-concurrency]]></category>
            <category><![CDATA[multithreading]]></category>
            <dc:creator><![CDATA[Ajay Kumar Namdev]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 13:11:07 GMT</pubDate>
            <atom:updated>2018-05-25T09:00:56.393Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Sequetial execution vs Concurrent execution — </strong>Sequential execution means single thread execution it takes more time to complete all method execution. Whereas concurrent execution means multithreaded execution it takes less time to complete all mehtods execution. To have concurrent execution developer must create user defined thread in program.</p><p><strong>Definition of Thread -</strong></p><ul><li>A thread is an independent sequential flow of execution/path.</li><li>A thread is a stack created in Java Stack Area.</li><li>It executes methods in sequence one after one.</li></ul><p><strong>Definition of Multithreading -</strong></p><p>It is the process of creating multiple threads in JSA for executing multiple tasks concurrently to finish their execution in short time by using Processor ideal time effectively.</p><p><strong>When multithreading programming is suitable -</strong></p><p>To complete independent multiple tasks execution in short time we should develop multithreading in multithreading bases programming CPU ideal time is utilized effectively.</p><p><strong>How can we create user defined thread in JVM?</strong></p><p>In JVM user defined thread is created and can start its execution — by creating Thread class object and by calling its method start.</p><p><strong>Introduction to </strong>run <strong>method -</strong></p><ol><li>It is initial point of user defined thread execution.</li><li>It is actually defined in Runnable interface and is implemented in Thread class.</li><li>It is implemented as empty mehtod in Thread class.</li><li>To excute out logic in user defined thread we must override run method.</li></ol><p><strong>Different ways to create custome threads in java</strong></p><p>In java we can create user defined threads in two ways</p><p>/* Custom thread extending from Thread */</p><p><strong>class </strong>MyThread <strong>extends </strong>Thread {</p><pre><strong>public void </strong>run() {<br>        System.<strong><em>out</em></strong>.println(<strong>&quot;run&quot;</strong>) <br>    }<br>    <br>    <strong>public static void </strong>main(String[] args) {<br>        System.<strong><em>out</em></strong>.print(<strong>&quot;main&quot;</strong>);<br>        MyThread mt = <strong>new </strong>MyThread();<br>        mt.start();<br>    }<br>}</pre><pre>/* Custom thread implementing from Runnable EOD */</pre><pre><strong>class </strong>MyThread <strong>implements Runnable</strong> {<br>    <strong>public void </strong>run() {<br>        System.<strong><em>out</em></strong>.println(<strong>&quot;run&quot;</strong>) <br>    }<br>    <br>    <strong>public static void </strong>main(String[] args) {<br>        System.<strong><em>out</em></strong>.print(<strong>&quot;main&quot;</strong>);<br>        MyThread mt = <strong>new </strong>MyThread();</pre><pre>Thead t1 = new Thread(mt);<br>        t1.start();<br>    }<br>}</pre><p>In the first approch when we create subclass object, Thread class object is also created by using its no-arg constructor. Them when start method is called using subclass object custom thread is created in Java Stack Area, and its execution is started by executing run() method from subclass based on processor busy.</p><p>In the second approch when we create subclass object Thread class object is not created because it is not a subclass of Thread. So to call start method we should create Thread class object explicitly by using Runnable parameter constructor, then using this Thread class object we should call start method. Then custom thread is created in Java Stacks Area, and its execution is started by executing run() mehtod from Runnable interface subclass based on processor busy.</p><p><strong>For more Multithreading Concept click </strong><a href="http://www.javatechworld.com/2017/06/java-thread-class-constructor.html"><strong>Next</strong></a></p><p>Source:</p><p><a href="http://www.javatechworld.com/prime-number-program-in-java/">http://www.javatechworld.com/prime-number-program-in-java/</a></p><p><a href="http://www.javatechworld.com/difference-between-throw-and-throws/">http://www.javatechworld.com/difference-between-throw-and-throws/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d39481075a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[java tutorial- Multithreading in java by javatechworld]]></title>
            <link>https://medium.com/@ajaykumarnamdev/java-tutorial-multithreading-in-java-by-javatechworld-a505ac939826?source=rss-ac373ab5a519------2</link>
            <guid isPermaLink="false">https://medium.com/p/a505ac939826</guid>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[multitasking]]></category>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ajay Kumar Namdev]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 13:05:18 GMT</pubDate>
            <atom:updated>2017-07-11T13:07:13.583Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Guys, Before understanding multithreading let us quickly review multitasking.</p><p><strong>Multitasking and types of multitasking -</strong></p><p>Executing multiple tasks at a time is called multitasking.</p><p><strong>Ex:</strong> while typing we can download a file, we can listen to music. It is called multitasking</p><p><strong>Multitasking is of two types -</strong></p><ol><li>Process based multitasking</li><li>Thread based multitasking</li></ol><p><strong>Process based multitasking</strong></p><p>Executing multiple tasks simultaneously is called process based multitasking here each task is a separate independent process.</p><p><strong>Thread based multitasking</strong></p><p>Executing multiple tasks concurrently is called thread based multitasking here each task is a seperate independent part of a single process. That part is called thread.</p><p><strong>Advantage of multitasking</strong></p><p>it is a process based or thread based multitasking the advantage of multitasking is to imporove the performance of the system be decreasing the response time.</p><p><strong>The difference between multitasking and multithreading</strong></p><p>Multitasking is a heavy weight because switching between contexts is slow because each process is stored at seperate address</p><p>Multithreading is a light weight because switching between contexts is fast because each thread is stored in same address.</p><p><strong>Overview on Java threads</strong><br>We can consider JVM is also a process, when JVM is created in its Java stacks area by default two threads are created with names</p><ol><li>main — to execute Java methods.</li><li>garbase collector — to destroy unreferenced objects.</li></ol><p>So by default Java is multithreaded programming language.</p><p>All methods are executed in main thread in sequence in the order they are called from main method as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*HCGbdNU8QFZy7_BL.PNG" /><figcaption>Multithreading Example</figcaption></figure><p><strong>For more multithreading concept click </strong><a href="http://www.javatechworld.com/2017/06/multithreading-in-java-part-two.html"><strong>Next</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a505ac939826" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>