<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forums - The Java Community - Threads</title>
		<link>http://www.javaprogrammingforums.com/</link>
		<description><![CDATA[Java program's path of execution.]]></description>
		<language>en</language>
		<lastBuildDate>Tue, 21 May 2013 18:06:37 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.javaprogrammingforums.com/images/misc/rss.png</url>
			<title>Java Programming Forums - The Java Community - Threads</title>
			<link>http://www.javaprogrammingforums.com/</link>
		</image>
		<item>
			<title>ContribSurvey library - A FREE CODEIGNITER SURVEY LIBRARY</title>
			<link>http://www.javaprogrammingforums.com/threads/29560-contribsurvey-library-free-codeigniter-survey-library.html</link>
			<pubDate>Tue, 21 May 2013 06:19:10 GMT</pubDate>
			<description><![CDATA[ContribSurvey is a flexible, self-hosted library with ability to create backend web apps for managing simple web-based surveys & feedback forms. 
			...]]></description>
			<content:encoded><![CDATA[<div>ContribSurvey is a flexible, self-hosted library with ability to create backend web apps for managing simple web-based surveys &amp; feedback forms.<br />
			<br />
Its a free library where you can just download and install ContribSurvey on your own web server running CodeIgniter and from then on you then have complete control over your data and your application. You (or your web team) can integrate ContribSurvey into your own website or intranet seamlessly to ensure your surveys give a polished, professional impression to your site viewers.<br />
<br />
<a href="http://www.developers.contrib.com/opensource" target="_blank">Contrib Developers</a><br />
<a href="mailto:contribcom@gmail.com">contribcom@gmail.com</a><br />
<br />
<br />
<a href="http://www.javaprogrammingforums.com/attachments/threads/2091d1369117233-contribsurvey-library-free-codeigniter-survey-library-desc-surveyscreen-jpg"  title="Name:  desc-surveyscreen.jpg
Views: 0
Size:  10.9 KB">desc-surveyscreen.jpg</a></div>


	<div style="padding:10px">

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Images</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.javaprogrammingforums.com/images/attach/jpg.gif" alt="File Type: jpg" />
	<a href="http://www.javaprogrammingforums.com/attachments/threads/2091d1369117233-contribsurvey-library-free-codeigniter-survey-library-desc-surveyscreen-jpg">desc-surveyscreen.jpg</a> 
(10.9 KB)
</li>
			</ul>
			</fieldset>
	

	

	</div>
]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>contrib</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29560-contribsurvey-library-free-codeigniter-survey-library.html</guid>
		</item>
		<item>
			<title>Is it possible to acceessdifferent parts of class by different threads?</title>
			<link>http://www.javaprogrammingforums.com/threads/29549-possible-acceessdifferent-parts-class-different-threads.html</link>
			<pubDate>Mon, 20 May 2013 17:34:14 GMT</pubDate>
			<description><![CDATA[Hi !my doubts are based on below programme. 
------------------------------------------------------------------  
    <div class="bbcode_container">...]]></description>
			<content:encoded><![CDATA[<div>Hi !my doubts are based on below programme.<br />
------------------------------------------------------------------ <br />
    <div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">class C implements Runnable  
    {  
    public void f1()  
    {  
    System.out.println(&quot;Hi&quot;);  
    }  
    public void run()  
    {  
    f1();  
    }  
    synchronized void f2()  
    {  
    System.out.println(&quot;Hello&quot;);  
    }  
    }  
    class synchronized  
    {  
    public static void main (String args&#91;&#93;)  
    {  
    C c1=new C();  
    Thread t1=new Thread(c1);  
    Thread t2=new Thread(c1);  
    t1.start();  
    t2.start();  
    }  
    }</pre></div></code><hr />
</div> ------------------------------------------<br />
Here c1 is object of class C.<br />
I have accessed method f1 of object c1 by threads t1 and t2.<br />
My Doubt:<br />
I want to access method f1 by thread t1 and f2 by thread t2.<br />
Is it possible?<br />
If possible please tell me</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>me_shankara</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29549-possible-acceessdifferent-parts-class-different-threads.html</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] ConcurrentModificationException - Tried Synchronizing, ListIterator, etc.]]></title>
			<link>http://www.javaprogrammingforums.com/threads/29379-concurrentmodificationexception-tried-synchronizing-listiterator-etc.html</link>
			<pubDate>Fri, 10 May 2013 03:38:37 GMT</pubDate>
			<description><![CDATA[Hello all, 
 
I rarely come across a Java problem I can't figure out myself but this one's got me stumped.  Basically I have a program that needs to...]]></description>
			<content:encoded><![CDATA[<div>Hello all,<br />
<br />
I rarely come across a Java problem I can't figure out myself but this one's got me stumped.  Basically I have a program that needs to run an update everyday.  In order to maximize efficiency I made this multi-threaded and put a cap on the number of concurrent threads that can run.  So the update function basically creates a List&lt;Thread&gt; of threads and then creates another list of Active Threads (also a List&lt;Thread&gt;).  Both of which are ArrayLists.  Then it runs through a while loop (below) and starts threads when the number of active threads is below a certain number and then scans the list to remove any threads which are finished.  The threads themselves have a few boolean statuses (started, finished, etc.) and synchronized functions to access those variables.  I keep getting ConcurrentModificationExceptions (the line is noted in the below code) I imagine because the UpdateThread objects are changing themselves (changing some boolean variables when they're finished).  I tried throwing a synchronized block around the loop code (even though I feared that would hurt the performance), I tried a ListIterator, etc. but it still didn't work.  The UpdateThread objects themselves just connect to a website, download some data, parse it and then upload it to a local database, but I don't think that's what's causing the issues, just FYI.<br />
<br />
If anyone has any ideas I'd greatly appreciate it, the sooner I get this working the better, it's the last component of the program.<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        //Execute the threads, removed completed ones, until all threads are done
        List&lt;UpdateThread&gt; activeThreads = new ArrayList&lt;UpdateThread&gt;();
        while(!threads.isEmpty() || !activeThreads.isEmpty())
        {
            //Check if we can add more threads
            while(activeThreads.size() &lt; UpdateThread.MAX_CONCURRENT_THREADS &amp;&amp; threads.size() &gt; 0)
            {
                //Add next thread to active threads until full
                activeThreads.add(threads.remove(0));
            }
            //Update the active threads list, start any unstarted, remove any finished
            for(UpdateThread ut : activeThreads)   // *** ERROR is thrown HERE
            {
                if(ut.isFinished())
                {
                    //Remove any finished
                    if(ut.success())
                    {
                        updatedSuccessfully++;
                    }
                    activeThreads.remove(ut);
                    updated++;
                }
                else if(ut.isRunning() == false)
                {
                    //Start any unstarted
                    ut.start();
                }
                else{
                    //Do nothing, running but not done
&nbsp;
                }
            }
            //Sleep
            try{
                Thread.sleep(UpdateThread.UPDATE_THREAD_CHECK_SLEEP);
            }catch(Exception e)
            {
                //Do Nothing
            }
        }</pre></div></code><hr />
</div> <br />
Thanks!<font color="Silver"><br />
<br />
--- Update ---<br />
<br />
</font>Figured it out, I'm an idiot.  Just had to remove it using the iterator:<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            //Update the active threads list, start any unstarted, remove any finished
            Iterator&lt;UpdateThread&gt; iter = activeThreads.iterator();
            while(iter.hasNext())
            {
                UpdateThread ut = iter.next();
                if(ut.isFinished())
                {
                    //Remove any finished
                    if(ut.success())
                    {
                        updatedSuccessfully++;
                    }
                    iter.remove();
                    updated++;
                }
                else if(ut.isRunning() == false)
                {
                    //Start any unstarted
                    ut.start();
                }
                else{
                    //Do nothing, running but not done
&nbsp;
                }
            }
            //Sleep
            try{
                Thread.sleep(UpdateThread.UPDATE_THREAD_CHECK_SLEEP);
            }catch(Exception e)
            {
                //Do Nothing
            }</pre></div></code><hr />
</div> <br />
In case anyone else has this issue, here you go.  Works like a charm.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>DougD720</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29379-concurrentmodificationexception-tried-synchronizing-listiterator-etc.html</guid>
		</item>
		<item>
			<title>What is The use of Thread class constructors?</title>
			<link>http://www.javaprogrammingforums.com/threads/29161-what-use-thread-class-constructors.html</link>
			<pubDate>Sun, 05 May 2013 05:40:10 GMT</pubDate>
			<description>Hi!My doubt is on Thread class constructors 
1)public Thread() 
2)public Thread(String name) 
The above two are two constructors of thread class....</description>
			<content:encoded><![CDATA[<div>Hi!My doubt is on Thread class constructors<br />
1)public Thread()<br />
2)public Thread(String name)<br />
The above two are two constructors of thread class.<br />
First constructor is used to create object of thread class.<br />
Second constructor is also used to create object of thread class with required name.<br />
If we write<br />
1)Thread t1=new Thread();<br />
This creates a thread class object t1.<br />
2)Thread t2=newThread(“MYTHREAD”);<br />
This also creates Thread class object t2 .It also creates thread with name &quot;MYTHREAD&quot;.<br />
My questions are<br />
1)What is the benefit of above t1,t2;<br />
2)How can we use the thread class objects t1,t2?<br />
3)Is it possible to execute run method of the thread &quot;MYMTHREAD&quot;?<br />
4)Suppose we have extended class named “a” from Thread class like below.<br />
Then how can we use t1,t2 on below class “a”?<br />
Is it possible to create thread to below class “a” with required name by using above constructors?<br />
Class  a  extends Thread  <br />
{  <br />
Public void run()  <br />
{  <br />
System.out.println(“Hi”);  <br />
}  <br />
}</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>me_shankara</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29161-what-use-thread-class-constructors.html</guid>
		</item>
		<item>
			<title>Why my programmi s not using all CPU power?</title>
			<link>http://www.javaprogrammingforums.com/threads/29131-why-my-programmi-s-not-using-all-cpu-power.html</link>
			<pubDate>Sat, 04 May 2013 06:21:46 GMT</pubDate>
			<description><![CDATA[I have this code: 
<div class="bbcode_container"> 
                 
<div class="bbcode_description" style="height:24px; background-image:...]]></description>
			<content:encoded><![CDATA[<div>I have this code:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 16, 10,TimeUnit.MINUTES,  new LinkedBlockingQueue&lt;Runnable&gt;() );
		executor.allowCoreThreadTimeOut(true);
		for(int  i = 0; i &lt; 16;i++)
		{
			executor.execute(new neuralNetwork());
			try 
			{
				Thread.sleep(1000);
			} 
			catch (InterruptedException e) 
			{
				e.printStackTrace();
			}
		}</pre></div></code><hr />
</div> Why my program is not using all CPU power?I have 4 cores with hyperthreading .  The program is using only 1.I am no linux mint.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>ddscs</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29131-why-my-programmi-s-not-using-all-cpu-power.html</guid>
		</item>
		<item>
			<title>thread/timer/sound  interaction</title>
			<link>http://www.javaprogrammingforums.com/threads/29113-thread-timer-sound-interaction.html</link>
			<pubDate>Fri, 03 May 2013 15:08:16 GMT</pubDate>
			<description>Good  morning ! 
I m new to Java  ,but I believe  this question  about  thread  organisation in my program ..Can you  please   help me to optimize it...</description>
			<content:encoded><![CDATA[<div>Good  morning !<br />
I m new to Java  ,but I believe  this question  about  thread  organisation in my program ..Can you  please   help me to optimize it ? <br />
Program  has  to do count  time  and show it on display  and at the same time   play  appropriate  sound  (frequency  of sound  is taken from  array freq[]<br />
.When  i  m trying to run program  it  produced  appropriate  sounds  ,but timer slows down  and count time  with  delays  up to 10 seconds ...<br />
What should i do ? <br />
Thank you  very much <br />
Edward<br />
Here  is  code <br />
import java.util.Locale;<br />
import java.io.IOException;<br />
import java.io.ObjectInputStream;<br />
import javax.sound.sampled.*;<br />
import java.text.*;<br />
import java.text.DateFormat;<br />
import java.util.Calendar;<br />
import java.applet.*;<br />
import java.awt.*;<br />
import java.util.*;<br />
import java.text.SimpleDateFormat;<br />
<br />
<br />
public class clock extends Applet implements Runnable{<br />
   Thread t,t1;<br />
   public static float SAMPLE_RATE = 8000f;<br />
   public int rem60(int a){<br />
	  int k = (a% 60);  <br />
	   <br />
		 k=60-Math.abs(k); <br />
	   <br />
	   return k;<br />
   }<br />
   public static void sound60(double hz, int msecs, double vol)<br />
		      throws LineUnavailableException {<br />
<br />
		         if (hz &lt;= 0)<br />
		             throw new IllegalArgumentException(&quot;Frequency &lt;= 0 hz&quot;);<br />
<br />
		         if (msecs &lt;= 0)<br />
		             throw new IllegalArgumentException(&quot;Duration &lt;= 0 msecs&quot;);<br />
<br />
		         if (vol &gt; 1.0 || vol &lt; 0.0)<br />
		             throw new IllegalArgumentException(&quot;Volume out of range 0.0 - 1.0&quot;);<br />
<br />
		         byte[] buf = new byte[(int)SAMPLE_RATE * msecs / 1000];<br />
<br />
		         for (int i=0; i&lt;buf.length; i++) {<br />
		             double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI;<br />
		             buf[i] = (byte)(Math.sin(angle) * 127.0 * vol);<br />
		         }<br />
<br />
		         // shape the front and back 10ms of the wave form<br />
		         for (int i=0; i &lt; SAMPLE_RATE / 100.0 &amp;&amp; i &lt; buf.length / 2; i++) {<br />
		             buf[i] = (byte)(buf[i] * i / (SAMPLE_RATE / 100.0));<br />
		             buf[buf.length-1-i] =<br />
		              (byte)(buf[buf.length-1-i] * i / (SAMPLE_RATE / 100.0));<br />
		         }<br />
<br />
		         AudioFormat af = new AudioFormat(SAMPLE_RATE,8,1,true,false);<br />
		         SourceDataLine sdl = AudioSystem.getSourceDataLine(af);<br />
		         sdl.open(af);<br />
		         sdl.start();<br />
		         sdl.write(buf,0,buf.length);<br />
		         sdl.drain();<br />
		         sdl.close();<br />
		     }<br />
   public void start(){<br />
      t = new Thread(this);<br />
      t.start();<br />
   }<br />
   public void run(){<br />
      t1 = Thread.currentThread();<br />
      while(t1 == t){<br />
         repaint();<br />
         try{<br />
            t1.sleep(1000);    <br />
         }<br />
         catch(InterruptedException e){}<br />
      }<br />
   }<br />
   public void paint(Graphics g){<br />
	  <br />
	   <br />
	   <br />
	   double[] ff={400,500,600};<br />
	 <br />
	    Calendar cal = new GregorianCalendar();<br />
	    Calendar cal0 = new GregorianCalendar();<br />
	    cal0.set(2013, 1, 13, 23, 56,04);<br />
	   <br />
	   <br />
	    <br />
	    int difDay =cal.get(Calendar.DAY_OF_YEAR)-cal0.get(Calendar.DAY_OF_YEAR);<br />
	    int difHour=cal.get(Calendar.HOUR_OF_DAY)-cal0.get(Calendar.HOUR_OF_DAY);<br />
	    int difMin=cal.get(Calendar.MINUTE)-cal0.get(Calendar.MINUTE);<br />
	    int difSec=cal.get(Calendar.SECOND)-cal0.get(Calendar.SECOND);<br />
	   <br />
	    int Day60= this.rem60(difDay);<br />
	    int Hour60= this.rem60(difHour);<br />
	    int Min60= this.rem60(difMin);<br />
	    int Sec60= 60-this.rem60(difSec);<br />
	    <br />
	      String DD = String.valueOf(Day60);<br />
	      String DH = String.valueOf(Hour60); <br />
	      String DM = String.valueOf(Min60);<br />
	      String DS = String.valueOf(Sec60);<br />
	     <br />
	<br />
	    <br />
       <br />
      String day  = String.valueOf(cal.get(Calendar.DAY_OF_YEAR));<br />
      String hour = String.valueOf(cal.get(Calendar.HOUR));<br />
      String minute = String.valueOf(cal.get(Calendar.MINUTE));<br />
      String second = String.valueOf(cal.get(Calendar.SECOND));<br />
    <br />
      <br />
      Font font = new Font(&quot;Serif&quot;, Font.BOLD, 12);<br />
      g.setFont(font);<br />
      <br />
      g.drawString(&quot;hour &quot;+ hour + &quot;minute :&quot; + minute + &quot;second :&quot; + second, 14, 30);<br />
      g.drawString(&quot;Day 60      :&quot;+DD,14,50);<br />
      g.drawString(&quot;Hour 60     : &quot;+DH,14,70);<br />
      g.drawString(&quot;Minutes 60  :&quot;+DM,14,90);<br />
      g.drawString(&quot;Secundes 60 :&quot;+DS,14,110);<br />
      <br />
     <br />
      <br />
      try {<br />
    	  double[] freq = {440, 469.86, 495.0,501.75, 528.64, 556.88, 594.39, 626.48, 660,704.79, 742.5, 792.86, 835.31//1<br />
 	           ,469.86, 501.75, 528.6,564.52,594.67, 634.73, 669, 704.79,752.63,792.89,846.67,892.01 //2<br />
 	         ,495,528.6,594.73,626.48,668.68, 704.79, 742.50, 792.89, 835.31, 891.97,939.73,//3<br />
 	        528.64 ,564.52,594.73,635.15,669.07,714.13,752.7,792.97,8  46.79,892.09,952.59,1003.6,//4<br />
 	      556.88,594.67,626.48,669.07,704.79,752.27,792.89,8  35.31,892.01,939.73,1057.19,//5<br />
 	            594.39, 634.73, 668.68,714.13,752.27,802.94,846.3,891.58,952.09,10  03.03,1071.06,1128.4,//6<br />
 	          626.48,669.0,704.79,752.7,792.89,846.3,892.01,939.  73,1003.51,1057.19,1113.75,1189.29,1252.97,//7<br />
 	        660,704.79,742.5,792.97,835.31,891.58,939.73,990,1  057.19,1113.75,1189.29,1252.97,//8<br />
 	            <br />
 	      704.79,752.63,792.89,846.79,892.01,952.09,1003.51,  1057.19,1128.95,1189.34,1270.01,1338,//9<br />
 	            742.5,792.89,835.31,892.09,939.73,1003.46,1057.19,  113.75,1189.34,1252.97,1337.95,1409.59,//10<br />
 	          792.86,846.67,891.97,952.59,1003.46,1071.06,1128.9  ,1189.29,1270.01,1337.95,1428.7,1505.19,//11<br />
 	        835.31,892.01,939.73,1003.6,1057.19,1128.4,1189.34  ,1252.97,1338.01,1409.59,1505.19,1585.79//12<br />
 	            <br />
 };<br />
    	  <br />
     for(int i=1; i&lt;55; i++){<br />
	this.sound60(freq[i],100,0.5);//day<br />
		<br />
		<br />
		<br />
    	}<br />
		<br />
	} catch (LineUnavailableException e) {<br />
	e.printStackTrace();<br />
	} <br />
      <br />
      <br />
     <br />
   }<br />
}</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>edwardone123</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/29113-thread-timer-sound-interaction.html</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Reply to all clients Multithreading]]></title>
			<link>http://www.javaprogrammingforums.com/threads/28983-reply-all-clients-multithreading.html</link>
			<pubDate>Wed, 01 May 2013 13:16:27 GMT</pubDate>
			<description><![CDATA[I have a server/client written. At the moment it's replying to individual clients (User one receives user one's post only) and I need multiple users...]]></description>
			<content:encoded><![CDATA[<div>I have a server/client written. At the moment it's replying to individual clients (User one receives user one's post only) and I need multiple users to receive all posts.<br />
<br />
<br />
Server <br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code Java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.util.*</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">class</span> ServerThread <span style="color: #7F0055; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a><span style="color: #000000;">&#123;</span>
	<span style="color: #7F0055; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> socket<span style="color: #000000;">;</span>
&nbsp;
	ServerThread<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> socket<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #7F0055; font-weight: bold;">this</span>.<span style="color: #000000;">socket</span> <span style="color: #000000;">=</span> socket<span style="color: #000000;">;</span>
	<span style="color: #000000;">&#125;</span>	
&nbsp;
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">void</span> run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #7F0055; font-weight: bold;">try</span>
		<span style="color: #000000;">&#123;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> message <span style="color: #000000;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprintwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">PrintWriter</span></a> pw <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprintwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">PrintWriter</span></a><span style="color: #000000;">&#40;</span>socket.<span style="color: #000000;">getOutputStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a> br <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a><span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #000000;">&#40;</span>socket.<span style="color: #000000;">getInputStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			br.<span style="color: #000000;">readLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<span style="color: #7F0055; font-weight: bold;">while</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>message <span style="color: #000000;">=</span> br.<span style="color: #000000;">readLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span> <span style="color: #3F7F5F; font-style: italic;">// while messages read them</span>
				pw.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span>message<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			socket.<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>	
			<span style="color: #7F0055; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Client disconnected&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #3F7F5F; font-style: italic;">// The server</span>
<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> Server<span style="color: #000000;">&#123;</span>
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> PORT <span style="color: #000000;">=</span> <span style="color: #cc66cc;">7777</span><span style="color: #000000;">;</span>
	<span style="color: #7F0055; font-weight: bold;">public</span> ArrayList<span style="color: #000000;">&lt;</span>Socket<span style="color: #000000;">&gt;</span> connections <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> ArrayList<span style="color: #000000;">&lt;&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #7F0055; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> <span style="color: #000000;">&#123;</span>
			<span style="color: #7F0055; font-weight: bold;">new</span> Server<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #000000;">run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">void</span> run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #7F0055; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a><span style="color: #000000;">&#123;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserversocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ServerSocket</span></a> serverSocket <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserversocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ServerSocket</span></a><span style="color: #000000;">&#40;</span>PORT<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span> 			<span style="color: #3F7F5F; font-style: italic;">// wait for request from PORT</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Server is listening for connections&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>			
&nbsp;
		<span style="color: #7F0055; font-weight: bold;">while</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> socket <span style="color: #000000;">=</span> serverSocket.<span style="color: #000000;">accept</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>						<span style="color: #3F7F5F; font-style: italic;">// listen and accept connection</span>
			connections.<span style="color: #000000;">add</span><span style="color: #000000;">&#40;</span>socket<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<span style="color: #7F0055; font-weight: bold;">new</span> ServerThread<span style="color: #000000;">&#40;</span>socket<span style="color: #000000;">&#41;</span>.<span style="color: #000000;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Client &quot;</span> <span style="color: #000000;">+</span> connections.<span style="color: #000000;">size</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
Client<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code Java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.util.*</span><span style="color: #000000;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> Client<span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #7F0055; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aunknownhostexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">UnknownHostException</span></a>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> 
	<span style="color: #000000;">&#123;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name <span style="color: #000000;">=</span> args<span style="color: #000000;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> socket <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span>, <span style="color: #cc66cc;">7777</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a> brFromClient <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a><span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #000000;">&#40;</span>socket.<span style="color: #000000;">getInputStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprintwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">PrintWriter</span></a> pw <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprintwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">PrintWriter</span></a><span style="color: #000000;">&#40;</span>socket.<span style="color: #000000;">getOutputStream</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		pw.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span>name<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a> brFromCmd <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> java.<span style="color: #000000;">io</span>.<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedReader</span></a><span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InputStreamReader</span></a><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">in</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		<span style="color: #7F0055; font-weight: bold;">while</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> readInput <span style="color: #000000;">=</span> brFromCmd.<span style="color: #000000;">readLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			pw.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span>name <span style="color: #000000;">+</span> <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #000000;">+</span> readInput<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span>brFromClient.<span style="color: #000000;">readLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
Any help is greatly appreciated..</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>ManInTheMiddle</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/28983-reply-all-clients-multithreading.html</guid>
		</item>
		<item>
			<title>synchronized block</title>
			<link>http://www.javaprogrammingforums.com/threads/28906-synchronized-block.html</link>
			<pubDate>Sat, 27 Apr 2013 16:53:22 GMT</pubDate>
			<description><![CDATA[The general form of synchronized block is 
<div class="bbcode_container"> 
                 
<div class="bbcode_description" style="height:24px;...]]></description>
			<content:encoded><![CDATA[<div>The general form of synchronized block is<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">class table 
{ 
....... 
void printTable(int n) 
{ 
synchronized(obj) 
{ 
...... 
} 
} 
}</pre></div></code><hr />
</div> Here obj means object of table class or object of any class.<br />
If we write this in place of obj ,then an object of table class can’t access the synchronized block from two different threads.<br />
MYDOUBTS:<br />
1)Is it possible to write name of object other than table class in place of obj?<br />
 2)If write other object’s name other than table class in place of obj,what it means?<br />
3)Then which object can’t access the synchronized block simultaneously?</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>me_shankara</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/28906-synchronized-block.html</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Code is running in multi-threading but it is neither pausing nor resuming..........]]></title>
			<link>http://www.javaprogrammingforums.com/threads/28861-code-running-multi-threading-but-neither-pausing-nor-resuming.html</link>
			<pubDate>Sat, 27 Apr 2013 07:10:06 GMT</pubDate>
			<description><![CDATA[I have created a JFrame here and you will also see JPanel and JLabel. I have also added two JButton "Pause" and "Resume" over there.  
 
What I am...]]></description>
			<content:encoded><![CDATA[<div>I have created a JFrame here and you will also see JPanel and JLabel. I have also added two JButton &quot;Pause&quot; and &quot;Resume&quot; over there. <br />
<br />
What I am trying to do is to pause and resume a child thread using JButtons, the program is running fine without any warning or errors, however, :confused: child thread is not pausing. The functions executes but it is not pausing the thread. <br />
<br />
I have attached two text files. All the functions are executing in &quot;Main.java&quot; file and &quot;child thread&quot; code is written child_1.java. <br />
<br />
Looking for quick help !!</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.javaprogrammingforums.com/images/attach/txt.gif" alt="File Type: txt" />
	<a href="http://www.javaprogrammingforums.com/attachments/threads/2042d1367046147-code-running-multi-threading-but-neither-pausing-nor-resuming-child_1-txt">child_1.txt</a> 
(966 Bytes)
</li><li>
	<img class="inlineimg" src="http://www.javaprogrammingforums.com/images/attach/txt.gif" alt="File Type: txt" />
	<a href="http://www.javaprogrammingforums.com/attachments/threads/2043d1367046148-code-running-multi-threading-but-neither-pausing-nor-resuming-main-txt">Main.txt</a> 
(1.8 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>pawan4angel</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/28861-code-running-multi-threading-but-neither-pausing-nor-resuming.html</guid>
		</item>
		<item>
			<title>Creating a Thread from a Thread</title>
			<link>http://www.javaprogrammingforums.com/threads/28799-creating-thread-thread.html</link>
			<pubDate>Fri, 26 Apr 2013 17:55:39 GMT</pubDate>
			<description><![CDATA[I have the following code: 
 
        Thread t = new Thread(){ 
             
            public void run(){ 
                System.out.println("I'm...]]></description>
			<content:encoded><![CDATA[<div>I have the following code:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code Java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a> t <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
            <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">void</span> run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;I'm called!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span><span style="color: #000000;">;</span>
&nbsp;
        <span style="color: #7F0055; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #000000;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #000000;">;</span> i <span style="color: #000000;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #000000;">;</span> i<span style="color: #000000;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
            t.<span style="color: #000000;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
            t.<span style="color: #000000;">join</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
            t <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a><span style="color: #000000;">&#40;</span>t<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
The question is, why the run method of a thread is invoked only twice (instead of 10 times)?</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/threads/">Threads</category>
			<dc:creator>angstrem</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/threads/28799-creating-thread-thread.html</guid>
		</item>
	</channel>
</rss>
