Asynchronized Multithreading Process

In our last blogs, we see multithreading process with isAlive() and join() methods. In this blog, we will see asynchronized multithreading process.

What is asynchronized multithreading process?

All time multiple process face thread interference and consistency problem because of asynchronized threading process.

 

In this program, we will see asynchronized multithreading process. Next blog will be on synchronized threading process.

Syn class in otherPack package : Display name in {}

package otherPack;

public class Syn

{

            public void display(String name)

            {

                        try

                        {

                                    System.out.print(” { ” + name );

                                    Thread.sleep(1000);

                                    System.out.println(” } “);

                        }

                        catch(Exception ex){}

            }

}


 SynNized class in classStore package : All process

package classStore;

import otherPack.*;

public class SynNized implements Runnable

{

            Thread t;

            Syn obj;

            String name;

            public SynNized(String name,Syn obj)

            {

                        t = new Thread(this);

                        this.obj = obj;

                        this.name = name;

                        t.start();

            }

            public void run()

            {

                        obj.display(name);

            }

}


Thread7 class in examples package

package examples;

import classStore.*;

import otherPack.*;

public class Thread7

{

                public static void main(String[] args)

                {

                                Syn obj = new Syn();

SynNized ob1 = new SynNized(“Dipak”,obj);

                                SynNized ob2 = new SynNized(“Umang”,obj);

                                SynNized ob3 = new SynNized(“Rohit”,obj);

                }

}

Output:

{ Dipak { Umang { Rohit }

}

}

 

Video also available on YouTube Java Program Channel


[sbscrbr_form]

If you have any query on blog example, you can directly comment us or subscribe our website


Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

156total visits,1visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

1 Comment

Leave a Reply

EmailEmail
PrintPrint