Created
August 15, 2013 20:53
-
-
Save InPermutation/6244763 to your computer and use it in GitHub Desktop.
What the hell is wrong with Java? http://stackoverflow.com/q/16159203/3140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
class A { | |
static Point currentPos = new Point(1,2); | |
class Point { | |
public int x; | |
public int y; | |
public Point(int x, int y) { | |
this.x = x; | |
this.y = y; | |
} | |
} | |
class Thready { | |
void f(Point p) { | |
lock(this) {} | |
if (p.x+1 != p.y) { | |
System.Console.WriteLine(p.x+" "+p.y); | |
System.Environment.Exit(1); | |
} | |
} | |
public void run() { | |
while(currentPos == null); | |
while(true) | |
f(currentPos); | |
} | |
} | |
public static void Main(String[] args) { | |
new Thread(new ThreadStart(new Thready().run)) | |
.Start(); | |
while (true) | |
currentPos = new Point(currentPos.x+1, currentPos.y+1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment