Isara Rungvitayakul
Isara Rungvitayakul

Reputation: 508

Java Animation Method

Comparing javax.swing.Timer, java.util.Timer and Thread, which method is the best CPU utilization for animation in Java and why ? The other method that not mentioned is also accepted.

Upvotes: 1

Views: 423

Answers (1)

jjnguy
jjnguy

Reputation: 138864

When working with GUI components you should always use javax.swing.Timer for animations.

The swing timer will help you execute your animation tasks on the correct thread. (The Event Dispatch Thread, or EDT)

To answer your specific question:

which method is the best CPU utilization for animation in Java and why ?

If used correctly, neither will affect CPU performance in a positive or negative way. They will essentially provide the exact same functionality.

Upvotes: 7

Related Questions