Multithreading

MULTITHREADING

Program to illustrate concept of multithreading was done as follows:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mythread extends Applet implements Runnable
{
Label l1,l2,l3;
Thread t1=new Thread(this);
public void init()
{
t1.start();
t1.setPriority(3);
t1.setPriority(2);
t1.setPriority(1);

}
@Override
public void run() {
// TODO Auto-generated method stub
l1=new Label(“l1″);
l1.setBounds(50,50,100,100);
add(l1);
try
{
Thread.sleep(5000);

}
catch(Exception e)
{
e.getMessage();
}
l2=new Label(“l2″);
l2.setBounds(50,250,100,100);
add(l2);
try
{
Thread.sleep(5000);

}
catch(Exception e)
{
e.getMessage();
}
l3=new Label(“l3″);
l3.setBounds(50,450,100,100);
add(l3);

try
{
Thread.sleep(5000);

}
catch(Exception e)
{
e.getMessage();
}
}

}

Advertisements

Constructive and genuine appreciation and/or criticism most welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s