Différence entre javax.swing.Timer et java.util.Timer

Résolu/Fermé
Pulsar360 Messages postés 114 Date d'inscription lundi 12 novembre 2012 Statut Membre Dernière intervention 29 août 2018 - 6 mai 2013 à 12:45
Pulsar360 Messages postés 114 Date d'inscription lundi 12 novembre 2012 Statut Membre Dernière intervention 29 août 2018 - 13 mai 2013 à 23:31
Bonjour,

Je suis débutant et je m'entraîne à coder en créant des petits jeux tous simple.
J'ai déjà utiliser javax.swing.Timer et java.util.Timer, mais je ne vois pas de différence entre les deux. Quels sont réellements les différence entre les deux?


On ma dit que java.util.Timer et conçu pour être utiliser avec des Threads (J'en utilise régulièrement). On ma également dit que javax.swing.Timer était plus "simple" d'utilisation, et java.util.Timer plus complet.

Quand est t'il réellement?

3 réponses

Pulsar360 Messages postés 114 Date d'inscription lundi 12 novembre 2012 Statut Membre Dernière intervention 29 août 2018 10
6 mai 2013 à 15:07
Personne pour m'éclairer?
0
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
6 mai 2013 à 18:38
Il y a aussi javax.management.timer.Timer si tu veux ^^

Plus sérieusement, la différence est expliquée dans la documentation, je cite :

https://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
In v 1.3, another Timer class was added to the Java platform: java.util.Timer. Both it and javax.swing.Timer provide the same basic functionality, but java.util.Timer is more general and has more features. The javax.swing.Timer has two features that can make it a little easier to use with GUIs. First, its event handling metaphor is familiar to GUI programmers and can make dealing with the event-dispatching thread a bit simpler. Second, its automatic thread sharing means that you don't have to take special steps to avoid spawning too many threads. Instead, your timer uses the same thread used to make cursors blink, tool tips appear, and so on.

You can find further documentation and several examples of using timers by visiting How to Use Timers, a section in The Java Tutorial.
0
Pulsar360 Messages postés 114 Date d'inscription lundi 12 novembre 2012 Statut Membre Dernière intervention 29 août 2018 10
13 mai 2013 à 23:31
Merci pour l'info.
0