Site icon WebArtDeveloper

How to Work with Threads in an Applet in Core Java

In this tutorial how to work with Threads in an Applet in Core Java is shown.

Code:

ThreadAppletDemo.java

/* <applet code=”ThreadAppletDemo.class” width=”1000″ height=”1000″> </applet>*/

import java.awt.*;
import java.applet.*;

public class ThreadAppletDemo extends Applet
{
public void paint(Graphics g)
{
for(int i=0;i<10;i++)
{
g.drawString(String.valueOf(i),200+(i*10),200);
try
{
Thread.sleep(2000);
}
catch(Exception e)
{
e.printStackTrace();
}
}

}

}

https://youtu.be/80Tv2MIMBWA

Exit mobile version