News for hackers. Stuff that matters.
Re:Rootbeer GPU Compiler Lets Almost Any Java Code Run On th... by damncabbage on Sunday August 12, 2012 @06:50AM (#4372312)

  4. sleeping while inside a monitor.
... Can someone clarify what this is?
Re:Rootbeer GPU Compiler Lets Almost Any Java Code Run On th... by mkross on Sunday August 12, 2012 @07:27AM (#4372344)

  // In Java, all instances of Object are also a monitor.
  // See https://en.wikipedia.org/wiki/Monitor_%28synchronization%29
  Foo myMonitor = new Foo()

  // To "enter" a monitor, you use 'synchronized'.
  synchronized (myMonitor) {
    // Inside the monitor, we could do a Thread.sleep.
    Thread.sleep(100);
  }
This is a very simplistic problem case. However, it is very possible for this to become a bigger problem. Because I can call arbitrary code when "inside" a monitor, it is very possible to call a method that does a sleep incidentally. (e.g. many implementations of IO operations will require some sort of sleep.)