4 ms·
new Thread() { public void run() { System.out.println("I'm in a Thread"); } }.start(); In C#: new Thread (Go).start(); static void
by mynameishere 18y ago
new Thread()
{
public void run()
{
System.out.println("I'm in a Thread");
}
}.start();
In C#:
new Thread (Go).start();
static void Go()
{
Console.Writeln("I'm in a Thread");
}
...C# isn't especially elegant either, but the general uncleanliness of inner anonymous classes is one example of Java's problems.
- prospero 18y agoThe C# version would actually be: new Thread(() => Console.WriteLine("I'm in a Thread")).Start();
- axod 18y agoSilly example though, as threads are silly.
- prospero 18y agoIs it really silly? Almost all the code I write day to day is either multi-threaded or event-driven, so the above difference means a very real improvement in my quality of life. The code is simpler, more compact, and easier to understand at a glance months later. This isn't the only difference, either. C# is never going to be as terse as a scripting language, but with each release they are examining common workflows and streamlining them. Java may be adding in a lot of new features, but the syntactic integration seems awkward at best. The little things count for a lot.