<?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 Forum - Learn Java Programming - Threads and Synchronization</title>
		<link>http://www.java-forums.org/</link>
		<description />
		<language>en</language>
		<lastBuildDate>Wed, 22 May 2013 13:11:01 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.png</url>
			<title>Java Programming Forum - Learn Java Programming - Threads and Synchronization</title>
			<link>http://www.java-forums.org/</link>
		</image>
		<item>
			<title>Is it possible to acceessdifferent parts of class by different threads?</title>
			<link>http://www.java-forums.org/threads-synchronization/73994-possible-acceessdifferent-parts-class-different-threads.html</link>
			<pubDate>Mon, 20 May 2013 17:39:26 GMT</pubDate>
			<description>Hi !my doubts are based on below programme. 
---------------------------------------------------------------- 
    class C implements Runnable   
   ...</description>
			<content:encoded><![CDATA[<div>Hi !my doubts are based on below programme.<br />
----------------------------------------------------------------<br />
    class C implements Runnable  <br />
    {  <br />
    public void f1()  <br />
    {  <br />
    System.out.println(&quot;Hi&quot;);  <br />
    }  <br />
    public void run()  <br />
    {  <br />
    f1();  <br />
    }  <br />
    synchronized void f2()  <br />
    {  <br />
    System.out.println(&quot;Hello&quot;);  <br />
    }  <br />
    }  <br />
    class synchronized  <br />
    {  <br />
    public static void main (String args[])  <br />
    {  <br />
    C c1=new C();  <br />
    Thread t1=new Thread(c1);  <br />
    Thread t2=new Thread(c1);  <br />
    t1.start();  <br />
    t2.start();  <br />
    }  <br />
    }  <br />
<br />
-------------------------------------------<br />
<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.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>me_shankara</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/73994-possible-acceessdifferent-parts-class-different-threads.html</guid>
		</item>
		<item>
			<title>More control over Thread and Runnable</title>
			<link>http://www.java-forums.org/threads-synchronization/73624-more-control-over-thread-runnable.html</link>
			<pubDate>Wed, 15 May 2013 20:22:15 GMT</pubDate>
			<description>I`ve just came  up with a solution for a program I am working on - it involves databasse querying, string checking, sortinge and other stuff, but...</description>
			<content:encoded><![CDATA[<div>I`ve just came  up with a solution for a program I am working on - it involves databasse querying, string checking, sortinge and other stuff, but everything is supposed to be on separate threads. So what I`ve invented is that code:<br />
<br />
Function.jaava:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public interface Function() {<br />
<br />
&nbsp;  public void fun();<br />
}</code><hr />
</div>Tasker.java:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.util.Map;<br />
import java.util.HashMap;<br />
<br />
public class Tasker {<br />
&nbsp; &nbsp; public static int item;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public static class Task {<br />
&nbsp; &nbsp; &nbsp; &nbsp; private static volatile boolean isRunning = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private static volatile boolean runner = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private Task() { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //disable for now<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static synchronized void init(final Function f) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Thread(new Runnable() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while ( runner ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Inside run()&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while ( isRunning() ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f.fun(); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception ex) { }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public static&nbsp; synchronized boolean isRunning() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return isRunning;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static synchronized void requestStop() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; runner = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isRunning = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static synchronized void kill() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isRunning = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; runner = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static&nbsp; synchronized void requestStart() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isRunning = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public static Task getInstance() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new Task();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; } //~ Close Task class <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; // Tasker methods<br />
&nbsp; &nbsp; private final static HashMap&lt;String, Task&gt; threads = <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new HashMap&lt;String, Task&gt; ();<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; public static HashMap&lt;String, Task&gt; getThreads() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return threads;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; //improved lazy method<br />
&nbsp; &nbsp; /* yet to be tested */<br />
&nbsp; &nbsp; public static Task getThreads(String name) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( threads.get(name) == null ) return null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else return threads.get(name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public static void newThread(String name) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( threads.get(name) == null ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; threads.put(name, Task.getInstance() );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;There is a task with name: &quot;+name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; public static void main(String&#91;&#93; args) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Tasker.newThread(&quot;countTo100&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  item = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  System.out.println(&quot;Starting initial&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Tasker.getThreads(&quot;countTo100&quot;).init(new Function() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  public void fun() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( item &gt; 200 ) Tasker.getThreads(&quot;countTo100&quot;).kill();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i &lt; 10; i++ ) System.out.print(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Tasker.getThreads(&quot;countTo100&quot;).requestStop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Tasker.getThreads(&quot;countTo100&quot;).requestStart();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; } // END OF MAIN&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
}</code><hr />
</div>The core idea is in init() method, there is one runnable that infinitely checks if the method in the run will be requested to start, also checks if the method will be requested to stop. To stop the whole run() you calll the kill method. You can compile and review my class and if you can tell me if it`s ready to go? I`ll test it tomorrow, replacing that code with the previous not that versatile one.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>heatblazer</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/73624-more-control-over-thread-runnable.html</guid>
		</item>
		<item>
			<title>advantage of Runnable over Thread</title>
			<link>http://www.java-forums.org/threads-synchronization/73578-advantage-runnable-over-thread.html</link>
			<pubDate>Wed, 15 May 2013 12:24:27 GMT</pubDate>
			<description>Hi All, 
here i am going to start a thread which is one of the most common question that is we have to way to create a thread in java. 
1-by...</description>
			<content:encoded><![CDATA[<div>Hi All,<br />
here i am going to start a thread which is one of the most common question that is we have to way to create a thread in java.<br />
1-by extending Thread class in our class<br />
2-by implementing Runnable interface into our class<br />
NOTE: implementing Runnable is always recommended to use.<br />
<br />
let me explain what i understand form my own way is that....<br />
1-generally, we extends a class into another class only when we want to enhanced its behavior by overriding the methods then we should extends the class ,but in the case of Thread class our main aim to achieve run() method inside our class and we do not override Thread class any method in our class instead of run(), so here Runnable would be the best choice because it contains only one method..<br />
2-if we extends Thread class in our class then by inheritance concept we won't be able to extend anymore class in our class as java does't support for multiple inheritance so here by doing this we are missing the inheritance benefit if once we extended Thread class instead of this if we implement Runnable interface then we can extends any class according to our requirement.<br />
<br />
instead of above any other real time benefit of Runnable over Thread ,please feel free to reply with your answer .<br />
your reply would be highly appreciated.<br />
<br />
feel free to correct me if i have stated wrong above.<br />
thanks for your time to read this thread.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>viki1719</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/73578-advantage-runnable-over-thread.html</guid>
		</item>
		<item>
			<title>Compiler error on constructor for thread class</title>
			<link>http://www.java-forums.org/threads-synchronization/73032-compiler-error-constructor-thread-class.html</link>
			<pubDate>Thu, 09 May 2013 16:04:33 GMT</pubDate>
			<description><![CDATA[I am using 
Windows 7/64 
NetBeans 7.2 
 
I am getting a IDE identified coding error message of  
 
"invalid method declaration; return type...]]></description>
			<content:encoded><![CDATA[<div>I am using<br />
Windows 7/64<br />
NetBeans 7.2<br />
<br />
I am getting a IDE identified coding error message of <br />
<br />
&quot;invalid method declaration; return type required&quot; on the public SAGESplashScreen () constructor.<br />
<br />
I need the constructor as I will be passing in arguments to the class to be used by the thread.<br />
<br />
I have reduced the code to the minimum that shows the error so as to not cloud the issue.<br />
<br />
I have no other SAGESplashScreeen class in my classpath.<br />
<br />
This code is based on several examples that I have found on the internet.<br />
<br />
It is my opinion that there is an issue with NetBeans (not neccessarily that NetBeans is broken rather I am not using it correctly).<br />
<br />
I have examined the properties for both the project and file but find not option in NetBeans that needs to be set to specify multithreaded program development.<br />
<br />
package sage;<br />
public class SAGESplashScreeen implements Runnable<br />
{<br />
    public SAGESplashScreen ()<br />
    {<br />
    }   // public SAGESplashScreen ()<br />
    <br />
    @Override<br />
    public void run()<br />
    {<br />
    }   //  public void run()<br />
}   // public class SAGESplashScreeen implements Runnable</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>ireland94</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/73032-compiler-error-constructor-thread-class.html</guid>
		</item>
		<item>
			<title>I need help in a synchronization threads</title>
			<link>http://www.java-forums.org/threads-synchronization/72943-i-need-help-synchronization-threads.html</link>
			<pubDate>Thu, 09 May 2013 02:18:04 GMT</pubDate>
			<description>Hello. I have a little problem and can not solve it. 
 
I am working in an exercise  which adds 1 and Subtract 1 ( two different threads ). 
...</description>
			<content:encoded><![CDATA[<div>Hello. I have a little problem and can not solve it.<br />
<br />
I am working in an exercise  which adds 1 and Subtract 1 ( two different threads ).<br />
<br />
Basically the output must be something like 0, 1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5 ,6, 7 ........................<br />
<br />
Here is all of my classes. Please help me i am stuck !!!!!!!!!<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class Main{<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String&#91;&#93; args){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Storage storage = new Storage();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Printer printer = new Printer(storage);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Adder adder = new Adder(storage);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Subtracter subtracter = new Subtracter(storage);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread printerThread = new Thread(printer, &quot;Printer&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread adderThread = new Thread(adder, &quot;Adder&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread subtracterThread = new Thread(subtracter, &quot;Subtracter&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printerThread.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adderThread.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; subtracterThread.start();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class Storage{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private int number = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Storage(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Storage(int number){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public synchronized void addNumber(int value){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait(250);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch(InterruptedException e){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = this.number + value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notifyAll();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public synchronized void subNumber(int value){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait(500);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch(InterruptedException e){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = this.number - value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notifyAll();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public synchronized void printSum(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait(250);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch(InterruptedException e){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(this.number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notifyAll();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class Adder implements Runnable {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Storage number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private int add = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Adder(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Adder(Storage number){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public void run(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number.addNumber(add);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.sleep(250);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (InterruptedException e) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class Subtracter implements Runnable {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Storage number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private int sub = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Subtracter(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Subtracter(Storage number){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public void run(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number.subNumber(sub);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.sleep(500);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (InterruptedException e) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class Printer implements Runnable {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Storage number = new Storage();<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Printer(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Printer(Storage number){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.number = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public synchronized void run() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //System.out.println(number.printSum());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number.printSum();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.sleep(250);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (InterruptedException e) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>Thanks</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>Alexis</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/72943-i-need-help-synchronization-threads.html</guid>
		</item>
		<item>
			<title>what is the  use of thread class constructors</title>
			<link>http://www.java-forums.org/threads-synchronization/72563-what-use-thread-class-constructors.html</link>
			<pubDate>Mon, 06 May 2013 12:14:04 GMT</pubDate>
			<description><![CDATA[Hi !My doubt is on Thread class constructors. My doubts based on below simple code. 
In below code ,in main method there is a statement as &#8221; Thread...]]></description>
			<content:encoded><![CDATA[<div>Hi !My doubt is on Thread class constructors. My doubts based on below simple code.<br />
In below code ,in main method there is a statement as &#8221; Thread C4=new Thread (new first(),&quot;FIRSTTHREAD&quot;);&#8221;<br />
This Statement Will create a Thread FIRSTTHREAD for the class &#8220;first&#8221;.<br />
Here we used Thread class constructor public Thread(Runnable target,String name);<br />
There are some other constructors in Thread class like<br />
1)public Thread();<br />
2)public Thread(String name);<br />
The first constructor is used to create an object of Thread class.<br />
The second constructor is used to create an object of Thread class but with required name.<br />
Then my question is<br />
--&gt;What is the benefit of creating object to thread class?<br />
--&gt;A class named with&#8221; four&#8221; is available in below code.By using second constructor of above constructors is it possible to write &#8220;four f1=new four(&#8220;MYTHREAD&#8221;);&#8221;<br />
-----------------------------------------------<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">class first implements Runnable <br />
&nbsp;  {&nbsp; <br />
&nbsp;  public void run() <br />
&nbsp;  {&nbsp; <br />
&nbsp;  System.out.println(Thread.currentThread().getName());<br />
&nbsp;  }&nbsp; <br />
&nbsp;  }&nbsp; <br />
&nbsp;  class four extends Thread&nbsp; <br />
&nbsp;  {&nbsp; <br />
&nbsp; public void run() <br />
&nbsp; {&nbsp; <br />
&nbsp; System.out.println(Thread.currentThread().getName()); <br />
&nbsp; }<br />
&nbsp; } <br />
&nbsp; class Third&nbsp; <br />
&nbsp; { <br />
&nbsp; public static void main(String args&#91;&#93;)&nbsp; <br />
&nbsp; {&nbsp; <br />
&nbsp;<br />
&nbsp;Thread C4=new Thread (new first(),&quot;FirstThread&quot;);<br />
&nbsp;C4.start(); <br />
&nbsp;<br />
&nbsp;}&nbsp; <br />
&nbsp;} <br />
&nbsp;<br />
&nbsp;Output:&nbsp; <br />
<br />
&nbsp;FirstThread</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>me_shankara</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/72563-what-use-thread-class-constructors.html</guid>
		</item>
		<item>
			<title>I believe it  is a thread problem</title>
			<link>http://www.java-forums.org/threads-synchronization/72298-i-believe-thread-problem.html</link>
			<pubDate>Fri, 03 May 2013 14:56:45 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.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>edwardone123</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/72298-i-believe-thread-problem.html</guid>
		</item>
		<item>
			<title><![CDATA[knight's tour in parallel]]></title>
			<link>http://www.java-forums.org/threads-synchronization/72018-knights-tour-parallel.html</link>
			<pubDate>Fri, 26 Apr 2013 13:50:45 GMT</pubDate>
			<description><![CDATA[Hi all,  
 
I am struggling with knight's tour in parallel. 
 Actually, I already have a sequential one. I would like to implement it based on the...]]></description>
			<content:encoded><![CDATA[<div>Hi all, <br />
<br />
I am struggling with knight's tour in parallel.<br />
 Actually, I already have a sequential one. I would like to implement it based on the sequential one.<br />
<br />
can anybody give me some advises?<br />
<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/threads-synchronization/">Threads and Synchronization</category>
			<dc:creator>followme_1987</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/threads-synchronization/72018-knights-tour-parallel.html</guid>
		</item>
	</channel>
</rss>
