No - this issue is not dependent on raw types. To demonstrate this, you can add a "<
String>" after every List or Set in the examples, and the results will be almost the same. You will no longer get the raw types warning, but you will still compile the first two, and get a compile error on the third. Why is that?
It actually depends on whether the types you are dealing with classes or interfaces, and on whether the classes in question are final.
In the first example, variable "list" has declared type List, and it is being cast to a Thread? Is this possible? Not usually, you would think... except that List is an interface. And Thread is not a final class. Which means that it is theoretically possible that a variable with declared type "List" might hold a reference to some class that extends Thread, and
also implements List. Such a design might be, well, stupid, but it's possible to do such a thing.
And even though we can clearly see that no such class is present in the code shown, it doesn't matter. The rules for casting depend only on the declared type of the thing you're casting (variable "list" in this case, whose declared type is List), and on the type you are casting it to. They do
not depend on anything else you may be able to figure out about what the variable
really refers to, no matter how obvious that information is. So, it doesn't matter that the variable "list" in this code actually refers to an ArrayList specifically. It matters only that the declared type is List, and that it's
possible for that to be cast to Thread, because it's
possible that there's a subclass of Thread that also implements List.
At least at compile time, that's all that matters. At run time, when the cast is executed, the JVM determines that the variable "list" actually references an ArrayList, not any subclass of Thread. So the cast fails with a ClassCastException.
Similar logic can be applied to the other two examples. Why does one compile, while the other does not? Try to think why one should be theoretically possible, while the other is not.