JAVA code to perform Multi threading.

What is threading ?

Guys, without wasting time let me explain threading in one line. Threading is a way to perform multi tasking, performing several tasks simultaneously. Programmatically threading means calling more than 1 functions or methods in parallel.

What is the purpose of threading?

  • It optimizes the code when code is performing independent tasks.
  • It increases the efficiency and productivity of the code’s output
  • It saves memory as variables are consumed in parallel manner thus freeing the memory in parallel as well
  • It minimizes the resource utilization
  • It minimizes the chances of server outage/crash
  • It helps in better/faster interaction or communication between client, server, resources and end consumer.
  • It improves quality of product.
  • It saves long queues to servers thus lesser time consumption.
  • It achieves multi tasking through concurrency.
  • Threading allows tasks isolation within the same process.

Usually a process with multiple threads share several resources, a thread has bounded and limited capability to interfere with other threads all lying within same process. This is useful and another major benefit because apart from some exceptions, a broken or a misbehaving thread will not bring down the entire application. All threads run independently with each other.

Below is a sample code for threading.

public class Thread_Tobo extends Thread
	Thread_Tobo(String name, String work)
	public void run() {
		 try {
	  System.out.println("My Name : "+My_Name);
	  System.out.println("My Work : "+My_Work);
		catch (Exception e) 
public static void main(String[] args) throws IOException 
Thread_Tobo t1 = null;
Thread_Tobo t2 = null;
	try {
t1 = new Thread_Tobo ("Tobo","Writer"); 
t2 = new Thread_Tobo ("Prateek","Developer"); 


My Name : Tobo
My Name : Prateek
My Work : Developer
My Work : Writer

4 thoughts on “JAVA code to perform Multi threading.

  1. With havin so much content do you ever run into any problems of plagorism or
    copyright violation? My website has a lot of completely unique content I’ve either written myself or outsourced but it looks like a lot of
    it is popping it up all over the web without my authorization. Do you know any techniques to
    help prevent content from being stolen? I’d definitely appreciate it.

  2. For latest news you have to pay a quick visit web
    and on world-wide-web I found this web page as a most excellent site for most up-to-date

Leave a Reply

Your email address will not be published.

Verified by MonsterInsights