Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185542

Expensive multi-core choke point when any graphics objects are created

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 10
    • client-libs
    • None
    • 2d
    • behavioral
    • minimal
    • Java API
    • SE

      Summary

      The applications are blocked in a small method, even if they use the different BufferedImages and different threads.

      Problem

      When the graphics object is created for BufferedImage it will call:

      GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      return env.createGraphics(this);

      The problem is that getLocalGraphicsEnvironment() is a static and synchronized method.

      Solution

      Reimplement the method to not require synchronization and drop the "synchronized" keyword from the getLocalGraphicsEnvironment() method to reduce the overhead of the method in multi-core environments.

      Specification

       java/awt/GraphicsEnvironment.java
      
       /**
        * Returns the local {@code GraphicsEnvironment}.
        * @return the local {@code GraphicsEnvironment}
        */
      -public static synchronized GraphicsEnvironment getLocalGraphicsEnvironment() {
      +public static GraphicsEnvironment getLocalGraphicsEnvironment() {

            serb Sergey Bylokhov
            serb Sergey Bylokhov
            Jim Graham, Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: