Static machine



  • What's the static line SomeThing mThing; ? static is like treating the class without using the object, And here it looks like a static object, but it probably can't be what this recording means?

    class SomeThing implements Runnable
    {
    public void run()       
     {
        System.out.println("Привет из побочного потока!");
     }
    }
    

    public class Program
    {
    static SomeThing mThing;

    public static void main(String[] args)
    {
    mThing = new SomeThing();

    Thread myThready = new Thread(mThing);  
    myThready.start();              
    
    System.out.println("Главный поток завершён...");
    

    }
    }

    example of this article https://habrahabr.ru/post/164487/



  • This is a static member of the class, a field in this case, and can be contacted by name of the class without the use of facilities.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2