Monday, 17 December 2012

Threads in java


class Thrchild implements Runnable
{
Thread t;
Thrchild()
{
t=new Thread(this,"Demo Thread");
System.out.println("Child Name"+t);
t.start();
}
public void run()
{
try
{
for(int i=1;i<=5;i++)
{
System.out.println("-->Child thread running"+i);
t.sleep(400);
}
}
catch(Exception e)
{
System.out.println("Exception in child"+e);
}
System.out.println("Child thread Completed");
}
}
public class Thrswitch {
public static void main(String arg[])
{
Thrchild tc=new Thrchild();
try
{
for(int i=1;i<=5;i++)
{
System.out.println("Main thread running"+i);
Thread.sleep(1000);
}
}
catch(Exception e)
{
System.out.println("Exception in main"+e);
}
System.out.println("Main thread Completed");
}
}

No comments:

Data Sharing

  1. Create Share CREATE SHARE my_share; 2. Grant privileges to share GRANT USAGE ON DATABASE my_db TO SHARE my_share; GRANT USAGE ...