please eslain me the flow of execution of this program
class Producer extends Thread
{
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void run(){
for(int i=1;i<=10;i++){
try{
sb.append(i+":");
Thread.sleep(100);
System.out.println("appending");
}catch(InterruptedException ie){}
}
dataprodover=true;
}
}
class Consumer extends Thread
{
Producer prod;
Consumer(Producer prod){
this.prod=prod;
}
public void run(){
try{
while(!prod.dataprodover)
Thread.sleep(10);
}catch(InterruptedException ie){}
System.out.println(prod.sb);
}
}
class Threadcom
{
public static void main(String[] args)
{
Producer pr = new Producer();
Consumer con = new Consumer(pr);
Thread t1 = new Thread(pr);
Thread t2 = new Thread(con);
t2.start();
t1.start();
}
}
View Answers
Ads
Related Tutorials/Questions & Answers:
please eslain me the flow of execution of this program
please eslain me the
flow of
execution of this program class Producer extends Thread
{
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void run(){
for(int i=1;i<=10;i++){
try
please tell me the flow of execution of this program
please tell
me the
flow of
execution of this program class Test{
int x;
Test(int x){
this.x=x;
}
static void access(){
System.out.println("x= "+x);
}}
class Static{
public static void main(String ar[]){
Test obj=new Test(55
Advertisements
Please explain me the flow of this program..
Please explain
me the
flow of this
program.. // Substring replacement.
class StringReplace {
public static void main(String args[]) {
String org = "This is a test. This is, too.";
String search
please explain me the flow of this program
please explain
me the
flow of this program class Bticket extends Thread
{
Object train,comp;
Bticket(Object train,Object comp){
this.train=train;
this.comp=comp;
}
public void run(){
synchronized
please help me in coding this given program
please help
me in coding this given program consider the below... are the prime numbers in ascending order
write a
program to find the nth term in this series.
(i m unable to code this
program..
please provide solution
please help me in coding this given program
please help
me in coding this given program consider the below... are the prime numbers in ascending order
write a
program to find the nth term in this series.
(i m unable to code this
program..
please provide solution
how can i write this program ?please suggest me
how can i write this
program ?
please suggest me
Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
urgent...pleAse help me.....please!
urgent...
pleAse help
me.....
please!
please help
me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
execution of java program
execution of java program wat are the steps for the
execution of the servlet-jdbc
program on tomcat 5.5 server..
PlS provide..the
execution steps... have put the classpath as:
set path=%path%;C:\
Program Files\Java\jdk1.6.0_01
please help me.
please help
me.
Please send
me a code of template in opencms and its procedure.so i can implement the code.
Thanks
trinath
help me please
help
me please Hello
I want helping for this question ,
Please
Write a
program that reads some friends� names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
please help me.
please help
me. How to read a properties file in java with a suitable example.
Please send
me.
Thanks
Trinath
Please visit the following link:
Java read properties file
execution of a jdbc program
execution of a jdbc program how to execute a servlet
program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows
*PLS provid the
execution steps in detail THANK YOU
please help me.
please help
me.
Please send
me the validation of this below link.
the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Thanks
Trinath