Write a Multithreading program in java to convert smile face into the crying face after 5 seconds and vice versa(Use Applet).

/*<applet code= "smileface.class" height="300" width="300"></applet>*/import java.awt.*;
import java.applet.*;
public class smileface extends Applet implements Runnable
{
    int aflag;
    Thread t;
    public void init() {
        t=new Thread(this); aflag=0;
        t.start();
    }
    public void run()
    {
        try        {
            if (aflag==0)
            {
                t.sleep(1000);
                aflag=1;
            } else            {
                t.sleep(1000);
                aflag=0;
            }
            repaint();
            run();
        }
        catch(Exception e)
        {
        }
    }
    public void paint(Graphics g) {
        34        g.drawOval(100,100,100,100);
        g.fillOval(120,125,20,20);
        g.fillOval(160,125,20,20);
        g.drawLine(150,135,150,165);
        if (aflag==0)
        { g.drawArc(140,160,20,20,0,-180);
            aflag=1;
        }
        else        {
            g.drawArc(140,160,20,20,0,180);
            aflag=0;
        }
    }
}