Home > Articles

Vacationing in Java

  • Print
  • + Share This
This chapter is from the book

Taking in a Ballgame at ESPN.com

The first afternoon stop on the Java tour will be a trip to the old ballgame. ESPN.com, one of the leading sports sites on the World Wide Web, is using Java to present baseball games as they happen in a visual, pitch-by-pitch fashion. To see how baseball is played in cyberspace, visit http://espn.com.

The Java program called ESPN GameCast presents each pitch in a major league game. Runners are shown on base, player changes are reflected immediately, and all stats in the game are updated in real time. It's a high-tech throwback to the period in the early 20th century when a large outdoor sign would be updated by hand with the score, men on base, and other information about an out-of-town game as it happened.

ESPN's GameCast program is a unique way to follow live games. Figure 3.4 shows GameCast after the last pitch in a thrilling 19-7 win by the Texas Rangers over the Boston Red Sox. (As a Rangers fan, I have to be thrilled about a win, because you never know when it's going to happen again.)

Figure 3.4 The Texas Rangers defeat the Boston Red Sox 19-7 in a game broadcast through ESPN GameCast, a Java program that displays comprehensive information about a game while it is taking place.

One of the things you might notice about ESPN GameCast is that it updates the day's scores from other games as you are using the program. This update is relatively easy to do because the Java language is multithreaded. Multithreading is a way for the computer to do more than one thing at the same time. One part of a program takes care of one task, another part takes care of a different task, and the two parts can pay no attention to each other. Each part of a program in this example is called a thread.

In a program such as ESPN GameCast, the league scoreboard along the top edge of the window could run in its own thread. The rest of the program could be another thread. If you use an operating system such as Microsoft Windows XP, you're using a type of this behavior when you run more than one program at the same time. If you're at work and you surf the Web for European aerobics videos in one window while running a company sales report in another window and making a long-distance call to a friend, congratulate yourself—you're multithreading!

  • + Share This
  • 🔖 Save To Your Account