Recent Posts
- NCC Punjab LDC Results 2013 NCCPunjab.com Interview Selected Candidates List
- RGUHS PGSSET Super Speciality 2013 Exam www.logisys.net.in Online Application
- RKCL RS-CIT Results 2013 rkcl.in RSCIT Final Exam May Result 2013
- TNEB Electricity Bills Online Payment tnebnet.org/awp/login Tamilnadu EB Payment System
- Kerala LET 2013 Fee Structure for 2013-14 Engineering College Admission
Discussion Forum
Java Threads Without Locks Example Program
You can find here Threads without locks example program.Here you can find the thread program based on without synchronized block menthod.
class TwoStrings {
static void print (String str1, String str2) {
System.out.print(str1);
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
e.printStackTrace();
}
System.out.println(str2);
}
}
class PrintStringsThread implements Runnable {
String str1, str2;
PrintStringsThread(String str1, String str2) {
this.str1 = str1; this.str2 = str2;
new Thread(this).start();
}
public void run() {
TwoStrings.print(str1, str2);
}
}
public class ThreadUnsyncDemo {
public static void main(String args[]) {
new PrintStringsThread (“Hello “, “there.”);
new PrintStringsThread (“How are “, “you?”);
new PrintStringsThread (“Thank you “,”very much!”);
}
}
Result:
Hello How are Thank you very much!
you?
there.
