MediaTracker - how to use it, what are the benefits, or is there an alterative?

后端 未结 2 420
后悔当初
后悔当初 2020-12-10 17:07

In the codebase we inherited the usage of MediaTracker was always done locally in each code block.

new MediaTracker(new Canvas());
mediatracker.addImage(i, 1         


        
相关标签:
2条回答
  • 2020-12-10 17:34

    MediaTracker was useful in 1995. Back then the primary GUI use of java was Applets, and Applets would usually load images slowly over the network.

    To make it easier for Applet writers, java gave us a nice MediaTracker api which would download images in the background, tracking when they were done, and even give notifications when images were partially loaded. The MediaTracker API meant Applet writers didn't have to block the application while images slowly downloaded, and didn't have to write complicated threading code to load images in background threads.

    These days you can typically load images synchronously, and it is best to use ImageIO. This is especially true for the common case where images are loaded from the local file system.

    0 讨论(0)
  • 2020-12-10 17:41

    MediaTracker

    ?

    Join us in the 3rd millennium and use ImageIO.read(File/URL/InputStream). In our millennium, MediaTracker is irrelevant.

    0 讨论(0)
提交回复
热议问题