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

java.awt.MediaTracker works wrong with threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.2.0
    • hotspot
    • sparc
    • solaris_2.5



      Name: dsC58869 Date: 07/30/98



      The java.awt.MediaTracker methods waitForAll() and checkAll()
      hang up VM under concurrent execution.

      ==== Here is the test demonstrating the bug ====

      /* The test creates MediaTracker and starts thread that tries to check
      image loading. Then it calls method waitForAll() method to load images.
      */

      import java.awt.*;
      import java.net.*;

      public class MediaTest002 extends Thread {

        MediaTracker tracker;
        Image[] image;

        public static void main (String[] args) {
          Canvas c = new Canvas();
          MediaTest002 test = new MediaTest002();
          test.start();
          System.out.println("wait");
          test.WAIT();
          System.out.println("wait done");
          System.exit(0);
        }

        public MediaTest002 () {
          Canvas c = new Canvas();
          tracker = new MediaTracker(c);
          
          String[] imagesName = {"im0.gif"};

          try {
            image = createImages(imagesName);
          } catch (MalformedURLException mue) {
          }
          for (int i = 0 ;i < image.length;i++) {
            tracker.addImage(image[i], i);
          }
        }

        public void WAIT () {
          try {
            tracker.waitForAll();
          } catch (Exception e) {
            System.out.println(e);
          }
        }
        public int getStatus() {
          return tracker.statusAll(false);
        }
        public void run() {
          while(!tracker.checkAll()) {
          }
        }

        public Image[] createImages(String[] images) throws MalformedURLException {
          Image[] ret = new Image[images.length];
          for(int i = 0; i < images.length; i++) {
            ret[i] = Toolkit.getDefaultToolkit().getImage(new URL("file:///home/sda/temp/tests/" + "images/" + images[i]));
          }
          return ret;
        }

      }

      <sda@spear(pts/10).331> java MediaTest002
      Font specified in font.properties not found [-monotype-arial-bold-r-normal-bold-*-%d-*-*-p-*-iso8859-5]
      Font specified in font.properties not found [-monotype-courier-regular-i-normal-italic-*-%d-*-*-m-*-iso8859-5]
      Font specified in font.properties not found [-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1]
      Font specified in font.properties not found [-b&h-lucida sans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1]
      Font specified in font.properties not found [-b&h-lucida sans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1]
      Font specified in font.properties not found [-b&h-lucida-bold-r-normal-bold sans-*-%d-*-*-p-*-iso8859-5]
      Font specified in font.properties not found [-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1]
      Font specified in font.properties not found [-monotype-arial-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-5]
      Font specified in font.properties not found [-monotype-arial-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-5]
      Font specified in font.properties not found [-b&h-lucida sans typewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1]
      Font specified in font.properties not found [-linotype-times-medium-r-normal--*-%d-*-*-p-*-iso8859-1]
      Font specified in font.properties not found [-b&h-lucida-bold-r-normal-bold sans-*-%d-*-*-p-0-iso8859-5]
      wait
      ^C<sda@spear(pts/10).332>

      ======================================================================
       Justification:
      The methods should work properly

      ======================================================================

            never Tom Rodriguez
            dsilaev Dmitri Silaev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: