Skip to content

Instantly share code, notes, and snippets.

@InPermutation
Created August 15, 2013 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InPermutation/6244763 to your computer and use it in GitHub Desktop.
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
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