Lara

8:00AM to 10:00AM (Threads)  

 

 Monday(09-01-2017)

 package com.lara;

interface A

{

            void test1();

}

class B

{

            void method1()

            {

                        System.out.println("from method1");

            }

            static void method2()

            {

                        System.out.println("from method2");

            }

}

public class Manager1

{

            public static void main(String[] args)

            {

                        B b1 = new B();

                        A a1 = b1 :: method1;

                        a1.test1();

                       

                        A a2 = new B() :: method1;

                        a2.test1();

                       

                       

                        A a3 = B :: method2;

                        a3.test1();

                       

                       

                       

                       

                       

            }

}

package com.lara;

class C

{

            void test1()

            {

                        System.out.println("from test1");

            }

            static void test2()

            {

                        System.out.println("from test2");

            }

}

public class Manager2

{

            public static void main(String[] args)

            {

                        Runnable r1 = new C() :: test1;

                        Thread t1 = new Thread(r1);

                        t1.start();

                       

                        Runnable r2 = C :: test2;

                        Thread t2 = new Thread(r2);

                        t2.start();

                       

                        Thread t3 = new Thread(new C() :: test1);

                        t3.start();

                       

                        Thread t4 = new Thread(C :: test2);

                        t4.start();

                       

                       

                        new Thread(new C() :: test1).start();

                       

                        new Thread(C :: test2).start();

                       

                       

                       

                       

                       

                       

            }

}

package com.lara;

interface D

{

            default void test1()

            {

                        System.out.println("from D.test1");

            }

            default void test2()

            {

                        System.out.println("from D.test2");

            }

}

class E implements D

{

           

}

public class Manager3

{

            public static void main(String[] args)

            {

                        E e1 = new E();

                        e1.test1();

                        e1.test2();

            }

}

package com.lara;

interface F

{

            static void test1()

            {

                        System.out.println("test1");

            }

            static void test2()

            {

                        System.out.println("test2");

            }

}

public class Manager4

{

            public static void main(String[] args)

            {

                        F.test1();

                        F.test2();

            }

}

package com.lara;

interface G

{

            default void test1()

            {

                        System.out.println("test1 from G");

            }

}

interface H

{

            default void test1()

            {

                        System.out.println("test1 from H");

            }

}

//interface I extends G, H

//{

//        

//}

 

//class J implements G, H

//{

//        

//}

 

public class Manager5

{

 

}

package com.lara;

interface K

{

            static void test1()

            {

                        System.out.println("test1 from K");

            }

}

interface L extends K

{

           

}

class M implements K

{

           

}

public class Manager6

{

            public static void main(String[] args)

            {

                        K.test1();

                        //L.test1();

                        //M.test1();

            }

}

package com.lara;

 

public interface Manager7

{

            public static void main(String[] args)

            {

                        System.out.println("Hello from Manager7");

            }

}

package com.lara;

public class Manager8

{

            public static void main(String[] args)

            {

                        Runnable r1 = () -> {

                                                                                                for(int i = 0; i < 100; i += 2)

                                                                                                {

                                                                                                            System.out.println(i);

                                                                                                            Thread.yield();

                                                                                                }

                                                                                    };

                                                                                   

                        Runnable r2 = () -> {

                                                                                                for(int i = 1; i < 100; i += 2)

                                                                                                {

                                                                                                            System.out.println(i);

                                                                                                            Thread.yield();

                                                                                                }

                                                                                    };

                        new Thread(r1).start();

                        new Thread(r2).start();

            }

}

package com.lara;

 

public class Manager9

{

            static void sleep(long millis)

            {

                        try

                        {

                                    Thread.sleep(millis);

                        }

                        catch(InterruptedException ex)

                        {

                                    ex.printStackTrace();

                        }

            }

            public static void main(String[] args)

            {

                        Runnable r1 = () -> {

                                                                                                for(int i = 0; i < 100; i++)

                                                                                                {

                                                                                                            System.out.println(i);

                                                                                                            sleep(100);

                                                                                                }

                                                                                    };

                        Thread t1 = new Thread(r1);

                        t1.start();

                        sleep(2000);

                        t1.suspend();

                        sleep(10000);

                        t1.resume();

            }

}