I came across some intresting things like threads where you can perform more than one task at a time
There are many methods you can apply on threads but in this one i'll be showing you how to create a thread and how to run it
1- in this example we can se how threads can be used it is a inbuilt class and we inherit it by using extends key word .Run is a function we dont need to call it it is automatically called
and we use our first function START used to start execution of thread making objects and calling are same
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
class first extends Thread
{
public void run()
{
for(int i=0;i<50;i++)
{
System.out.print("value of i is"+i);
}
}
}
class second extends Thread
{
public void run()
{
for(int k=0;k<50;k++)
{
System.out.println("value of k is"+k);
}
}
}
class tt
{
public static void main(String arg[])
{
first thread1=new first();
second thread2=new second();
thread1.start();
thread2.start();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
there are many functions or methods that we can apply on threads that i'll be discussing later so keep checking
There are many methods you can apply on threads but in this one i'll be showing you how to create a thread and how to run it
1- in this example we can se how threads can be used it is a inbuilt class and we inherit it by using extends key word .Run is a function we dont need to call it it is automatically called
and we use our first function START used to start execution of thread making objects and calling are same
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
class first extends Thread
{
public void run()
{
for(int i=0;i<50;i++)
{
System.out.print("value of i is"+i);
}
}
}
class second extends Thread
{
public void run()
{
for(int k=0;k<50;k++)
{
System.out.println("value of k is"+k);
}
}
}
class tt
{
public static void main(String arg[])
{
first thread1=new first();
second thread2=new second();
thread1.start();
thread2.start();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
there are many functions or methods that we can apply on threads that i'll be discussing later so keep checking
No comments:
Post a Comment