---
title: "Can you please explain this Thread working?"  
description: "Can you please explain this Thread working?"  
author: "Madam Walker"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1655/can-you-please-explain-this-thread-working  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Can you please explain this Thread working?

Heres the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) about threads.....I don't know the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) 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](https://www.mindstick.com/interview/34427/explain-the-output-in-angular) is Dog But why and how ?

## Replies

### Reply by Anonymous User

Because you override **Thread#run()**, so this method is eventually executed when you start the thread. The default Thread#run() delegates to the passed-in Runnable. Rule of thumb: Either provide a Runnable or override Thread#run(), but don't do both!


---

Original Source: https://www.mindstick.com/forum/1655/can-you-please-explain-this-thread-working

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
