<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Java_-_Create_new_Thread_via_Runnable</id>
	<title>Java - Create new Thread via Runnable - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Java_-_Create_new_Thread_via_Runnable"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Java_-_Create_new_Thread_via_Runnable&amp;action=history"/>
	<updated>2026-05-07T00:01:30Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Java_-_Create_new_Thread_via_Runnable&amp;diff=19668&amp;oldid=prev</id>
		<title>134.3.241.116: Die Seite wurde neu angelegt: „&lt;pre&gt; /*         Create New Thread Using Runnable Example         This Java example shows how to create a new thread by implementing         Java Runnable interfa…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Java_-_Create_new_Thread_via_Runnable&amp;diff=19668&amp;oldid=prev"/>
		<updated>2013-03-04T12:01:56Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „&amp;lt;pre&amp;gt; /*         Create New Thread Using Runnable Example         This Java example shows how to create a new thread by implementing         Java Runnable interfa…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
        Create New Thread Using Runnable Example&lt;br /&gt;
        This Java example shows how to create a new thread by implementing&lt;br /&gt;
        Java Runnable interface.&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * To create a thread using Runnable, a class must implement&lt;br /&gt;
 * Java Runnable interface.&lt;br /&gt;
 */&lt;br /&gt;
public class CreateThreadRunnableExample implements Runnable{&lt;br /&gt;
 &lt;br /&gt;
        /*&lt;br /&gt;
         * A class must implement run method to implement Runnable&lt;br /&gt;
         * interface. Signature of the run method is,&lt;br /&gt;
         *&lt;br /&gt;
         * public void run()&lt;br /&gt;
         *&lt;br /&gt;
         * Code written inside run method will constite a new thread.&lt;br /&gt;
         * New thread will end when run method returns.&lt;br /&gt;
         */&lt;br /&gt;
        public void run(){&lt;br /&gt;
               &lt;br /&gt;
                for(int i=0; i &amp;lt; 5; i++){&lt;br /&gt;
                        System.out.println(&amp;quot;Child Thread : &amp;quot; + i);&lt;br /&gt;
                       &lt;br /&gt;
                        try{&lt;br /&gt;
                                Thread.sleep(50);&lt;br /&gt;
                        }&lt;br /&gt;
                        catch(InterruptedException ie){&lt;br /&gt;
                                System.out.println(&amp;quot;Child thread interrupted! &amp;quot; + ie);&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
               &lt;br /&gt;
                System.out.println(&amp;quot;Child thread finished!&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
       &lt;br /&gt;
        public static void main(String[] args) {&lt;br /&gt;
               &lt;br /&gt;
                /*&lt;br /&gt;
                 * To create new thread, use&lt;br /&gt;
                 * Thread(Runnable thread, String threadName)&lt;br /&gt;
                 * constructor.&lt;br /&gt;
                 *&lt;br /&gt;
                 */&lt;br /&gt;
               &lt;br /&gt;
                Thread t = new Thread(new CreateThreadRunnableExample(), &amp;quot;My Thread&amp;quot;);&lt;br /&gt;
               &lt;br /&gt;
                /*&lt;br /&gt;
                 * To start a particular thread, use&lt;br /&gt;
                 * void start() method of Thread class.&lt;br /&gt;
                 *&lt;br /&gt;
                 * Please note that, after creation of a thread it will not start&lt;br /&gt;
                 * running until we call start method.&lt;br /&gt;
                 */&lt;br /&gt;
               &lt;br /&gt;
                t.start();&lt;br /&gt;
               &lt;br /&gt;
                for(int i=0; i &amp;lt; 5; i++){&lt;br /&gt;
                       &lt;br /&gt;
                        System.out.println(&amp;quot;Main thread : &amp;quot; + i);&lt;br /&gt;
                       &lt;br /&gt;
                        try{&lt;br /&gt;
                                Thread.sleep(100);&lt;br /&gt;
                        }&lt;br /&gt;
                        catch(InterruptedException ie){&lt;br /&gt;
                                System.out.println(&amp;quot;Child thread interrupted! &amp;quot; + ie);&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
                System.out.println(&amp;quot;Main thread finished!&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Typical output of this thread example would be&lt;br /&gt;
 &lt;br /&gt;
Main thread : 0&lt;br /&gt;
Child Thread : 0&lt;br /&gt;
Child Thread : 1&lt;br /&gt;
Main thread : 1&lt;br /&gt;
Main thread : 2&lt;br /&gt;
Child Thread : 2&lt;br /&gt;
Child Thread : 3&lt;br /&gt;
Main thread : 3&lt;br /&gt;
Main thread : 4&lt;br /&gt;
Child Thread : 4&lt;br /&gt;
Child thread finished!&lt;br /&gt;
Main thread finished!&lt;br /&gt;
 &lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>134.3.241.116</name></author>
	</entry>
</feed>