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

GraphicsEnvironment.getLocalGraphicsEnvironment() is not multi-thread safe

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      kestrel
    • CPU:
      generic
    • OS:
      generic

      Description


      algol.eng.sun.com% java -version
      java version "1.3"
      Classic VM (build JDK-1.3-J, native threads, sunwjit)
      algol.eng.sun.com% uname -a
      SunOS algol.eng.sun.com 5.8 s28_28 sun4u sparc SUNW,Ultra-2

      Additional machine information is attached.


      algol.eng.sun.com% cat MTG2D.java
      public class MTG2D extends Thread {
          private final static int NTHREADS=15;
          private final static int NITERS=10;
          public static void main (String argv[]) {
              MTG2D[] t = new MTG2D[NTHREADS];
              for (int i=0; i<NTHREADS; i++) t[i]=new MTG2D();
              for (int i=0; i<NTHREADS; i++) t[i].start();
              for (int i=0; i<NTHREADS; i++) {
                  try { t[i].join(); }
                  catch (InterruptedException e) { }
              }
              for (int i=0; i<NTHREADS; i++) System.out.println(t[i].gSave);
              System.out.println(success?"Success":"Fail");
              if (!success) System.exit(1);
          }
          private static boolean success=true;
          BufferedImage f = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB);
          GraphicsEnvironment gSave=null;
          public void run() {
              Graphics2D g2d = f.createGraphics();
              GraphicsEnvironment g =
                  GraphicsEnvironment.getLocalGraphicsEnvironment();
              yield();
              gSave = g;
          }
      }

      algol.eng.sun.com% javac -d . MTG2D.java
      algol.eng.sun.com% java MTG2D <----- Hung the first time
      ^Calgol.eng.sun.com% java MTG2D
      Segmentation Fault <----- Seg faulted the next

      allan.jacobs@Eng 1999-08-11

        Attachments

          Activity

            People

            Assignee:
            tnguyensunw Thanh Nguyen (Inactive)
            Reporter:
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: