Users Pricing

forum

Home Forums Can you please explain this Thread working? – MindStick

Can you please explain this Thread working?

Madam Walker 2132 14 Oct 2013

Heres the code about threads.....I don't know the difference between those 2 new() statements.


  Runnable r=new Runnable() {

    public void run() {
    System.out.print("Cat");
    }
    };
    Thread t=new Thread(r) {
    public void run() {
    System.out.println("Dog");
    }
    };
    t.start();



Output is Dog But why and how ?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md