please tell me
class Producer extends Thread
{
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void run(){
synchronized(sb){
for(int i=1;i<=10;i++){
try{
sb.append(i+":");
Thread.sleep(100);
System.out.println("appending");
}catch(Exception e){}
}
sb.notify();
}
}
}
class Consumer extends Thread
{
Producer prod;
Consumer(Producer prod){
this.prod=prod;
}
public void run(){
synchronized(prod.sb){
try{
prod.sb.wait();
}catch(Exception e){}
System.out.println(prod.sb);
}
}
class Threadcom1
{
public static void main(String[] args) throws Exception
{
Producer pr = new Producer();
Consumer con = new Consumer(pr);
Thread t1 = new Thread(pr);
Thread t2 = new Thread(con);
t2.start();
t1.start();
}
}
}
i got error as Inner class connot have static declarations
pls tell me the solution for this
View Answers
November 28, 2011 at 11:04 AM
class Producer extends Thread {
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void run(){
synchronized(sb){
for(int i=1;i<=10;i++){
try{
sb.append(i+":");
Thread.sleep(100);
System.out.println("appending");
}
catch(Exception e){}
}
sb.notify();
}
}
}
class Consumer extends Thread {
Producer prod; Consumer(Producer prod){
this.prod=prod;
}
public void run(){
synchronized(prod.sb){
try{
prod.sb.wait();
}
catch(Exception e){}
System.out.println(prod.sb);
}
}
}
class Threadcom1 {
public static void main(String[] args) throws Exception {
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 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 tell meplease tell me why we are using http protocol in servlets
Advertisements
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
please tell me();
^
1 error
tell me the resolution
please....
import...
please tell me import java.lang.Thread;
class Current{
public static void main(String ar[]){
Thread t = Thread.CurrentThread();
System.out.println
please tell me: '}' expected
^
2 errors, i got this error.......
please tell me the resolution...
please tell me class Person{
string name;
int age;
void talk(){
System.out.println("my name is"+name);
System.out.println
please tell meplease tell me which cmd we use to clear the screen in sql prompt
please tell meplease tell me why we use public static main(String ar){} in java instead of main
please tell meplease tell me select * from emp order by 5 desc;
in the above what is the meaning of 5, and what its functionality
please tell me));
^
1 error
please tell me the resolution of this
Hi...
please tell me import java.io.*;
class SString{
public static void main(String ar[]) throws IOException{
BufferedReader br = new Bufferedreader
please tell me(10.6,20.0);
^
1 error,
please tell me the resolution for this...
...
please tell me class Sample{
private double num1,num2;
void sample(double x,double y){
num1=x;
num2=y;
}
void Sum(){
double result=num1+num2
please tell meplease tell me what are the topics in core and advaced java....
Hi Friend,
Please visit the following links:
http://www.roseindia.net/
http://www.roseindia.net/java/
Thanks
Hi Friend,
Please visit
please tell meplease tell me Actually i am working on a Project tiitle is JavaMail System,
1)How to configure java mail API and a Demo Program for Sending mail and Receiving using JSP and Servlet
please tell me;
^
please tell me the resolution
class Reserve...
please tell me class Reserve extends Thread{
int available=1;
int wanted;
Reserve(int i){
wanted = i;
}
public static void
please tell meplease tell me class Producer extends Thread
{
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void... got error as Inner class connot have static declarations
pls
tell me please tell meplease tell me class Person{
int age;
String name;
void talk(){
System.out.println("my name is:"+name);
System.out.println("my age is:"+age);
}
}
class Hash{
public static void main(String ar[]){
Person raju=new Person
please tell meplease tell me
<tr>
<td><html:hidden property="tid" value="${user.id}"/></td>
<td><bean:write name="user" property="emp_name"/>
please tell meplease tell me Blockquote
Blockquote> BlockquoteBlockquote
how to get images from ms access databases to jsp pagesBlockquote
Jsp get image from ms access database
Create a table named user(id,name,address,image
please tell meplease tell me what is the source code if user give wrong user name password the explorer will show incorrect username password
<...);
}
%>
For more information,
please go through the following link:
http
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
please tell me about command line arguments in java?please tell me about command line arguments in java?
please tell me about command line arguments in java?
Hi Friend,
The command-line arguments are the arguments which are sent to the program being called. You can
please tell me about command line arguments in java?please tell me about command line arguments in java?
please tell me about command line arguments in java?
Hi Friend,
The command-line arguments are the arguments which are sent to the program being called. You can
Tell me - Java BeginnersTell me
how to create a valid.js file
please tell me and give the write code
Thanks Hi friend,
Please give details for requirement of this "valid.js" file.
For read more information
http
Tell me - StrutsDirectory Structure for Struts
Tell me the Directory Structure for Struts
Tell me - StrutsStruts tutorial to learn from beginning
Tell me, how can i learn the struts from beginning
Tell me - StrutsDirectory Structure with example program Execution
Tell me the Directory Structure with example program Execution
tell me coding for thistell me coding for this Write an application that displays the integer equivalents of the following character...A
Java get Integer value of Character
class GetIntValueOfCharacter
{
public static void main
plz tell meplz
tell me how to get no. of times the 'button' is pressed
Here is a java swing code that counts the number of times the button clicked... CountButtonClicks();
}
JButton button1 = new JButton("Click
Me!");
int clickCount
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
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
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.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
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
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. 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 help me to this problem..please help
me to this problem.. i wrote a program like keyboard... inside the JTextField) but i want to make this program to let
me write where i clicked (i.e allows
me to write any thing at the field where i clicked
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