Win a copy of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java this week in the Android forum!

vineeta pillai

Greenhorn
+ Follow
since Jan 18, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vineeta pillai

I think the problem with your code is that you are
first setting the colour to black and then setting it again to
white again before drawing the oval.
I Hope this will work.
import java.awt.*;
import java.applet.*;
public class SimplePaint extends Applet
{
public void paint(Graphics g)
{
g.drawRect(0,0,25,100);
g.setColor(Color.black);
g.fillOval(5,5,10,10,20,10);
g.setColor(Color.white);
}
}

17 years ago
Priya,
you are calling the synchronized method Dispaly() on different objects.
Different objects are created because a new variable is declared
each time the run() method of Thread1 is called as the object is declared
inside the run() method.
Synchronisation means holding lock on the synchronised methods of a single
object.
Here Display() is called by the first, second and third method independently
on different objects each having their own lock.
That's why you are getting unexpected result
My version:

Hi, Please use [ code] [ /code] tags to format your code. Thanks

[This message has been edited by Rahul Mahindrakar (edited January 19, 2001).]