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();
}
}
Related Tutorials/Questions & Answers:
please eslain me the flow of execution of this programplease 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 programplease 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 programplease 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 programplease 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 programplease 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 for this program - Java Beginnersplease help
me for this program Write a
program that asks the user for a starting value and an ending value and then writes all the integers (inclusive) between those two values.
Enter Start:
10
Enter End:
14
10
please help me in a java program !! - Java Beginnersplease help
me in a java
program !! the porgram should use...://en.wikipedia.org/wiki/Kosaraju_algorithm)
there are 4 classes in my
program : Vertex... and run the
program"
i still need to modify the method kosaraju in the class Graph
how can i write this program ?please suggest mehow 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
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.
Please send
me a code of template in opencms and its procedure.so i can implement the code.
Thanks
trinath
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
please help me to this problem..please help
me to this problem.. i wrote a
program like keyboard and i used [JTextFiled] means that just you can write inside the
program (i.e inside the JTextField) but i want to make this
program to let
me write where i
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
execution of java programexecution 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 tell meplease tell me i have created one table,when i close and again login, table name will be there, but its content not displayed, showing as no rows selected,
please tell
me the reason
please help me.please help
me. How to move the edits.jsp in below link?
http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Please give me coding for this..Please give
me coding for this.. Write an application that inputs... spaces each.For Example.if the user types the number 42339,the
program should print... happens when you execute the
program and type a number with more than five digits
please help me.please help
me. I have a jsp page under that i add a list box under i get the countries through my database.
so how can i do
Please give me the answer."int a=08 or 09" its giving compile time error why "int a=08 or 09" its giving compile time error why ?
can any one give
me the answer of this
please please guide me - EJBplease guide me Hi
I am Pradeep singh ,done SCJP 5.0 and SCWCD 5.0 .Now i want to learn further .So
please tell
me whether should i learn EJB 3.0... advice
me .At present i am jobless
execution of a jdbc programexecution 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. I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
Please help me.Please help
me. Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id?
http
please help me...please help
me... write an application that print number in the following order using a FOR-Loop
1 2 3 4 5
2 4 6 8 10
3 6 9 1215
4 8 121620
5 10152025
please help me in these progplease help
me in these prog
create 2 jdbc programs including awt
create 2 jdbc programs including swing
create 2 jdbc programs including command line argument
create 2 jdbc programs including io class
4 jdbc prog using
please help me before. This name list should get from the database.
Please help
me.
By the way, I'm...
please help me Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another
Please help mePlease help me
program for when a user enter his card number, it has to create default security pin in the database
please tell me, but its compiled and run successfully,
please tell
me the reason...
please tell me class Person{
int age;
String name;
void Person1(String g,int a){
name=g;
age=a;
}
Person(String s,int i){
name=s;
age=i;
}
void