i have a written a applet that uses wait and notify,but it is not working,, notify and wait will not work in applet? if you are interested i shall put the code..plz answer
Rahul Mahindrakar
Ranch Hand
Joined: Jul 28, 2000
Posts: 1829
posted
0
There should be no problem in using wait,notify , notifyAll() in an applet. Could you check up your code once more and if you still have problems put up the code over here. Regds. Rahul
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
thank you rahul for ur reply,it is not working, i am putting my code here...please tell me the problem ------------ import java.awt.*; import java.awt.event.*; import java.applet.*; /*<applet code=Count2 width=250 height=250> </applet>*/
public class Count2 extends Applet implements ActionListener { int c=0; String out; Counter1 c1; Restart r1; public Label l1; Thread t; volatile boolean pauseflag=true; volatile boolean waitflag=false; Count22 c22=new Count22(); public void init() { Button b1=new Button("Start"); Button b2=new Button("Pause"); l1=new Label(); b1.addActionListener(this); b2.addActionListener(this); add(b1); add(b2); add(l1); c1= new Counter1(); r1=new Restart(); } public void actionPerformed(ActionEvent an) {
} } //first thread ,increments the count and displays ..,and when pause button clicked it will go to sleep mode.. class Counter1 implements Runnable { Counter1() { Thread tty= new Thread(this,"newone"); tty.start(); } public void run() { c22.cc();
} } //second thread,each time it will call the notify,so if the other thread in sleep mode it will bring to ready to run mode class Restart implements Runnable { Restart() { Thread tty1= new Thread(this,"newone"); tty1.start(); } public void run() { c22.cc1();