Results 1 to 7 of 7
Like Tree2Likes
  • 1 Post By JosAH
  • 1 Post By awinston

Thread: timer

  1. #1
    Crowdy199 is offline Member
    Join Date
    Jun 2012
    Posts
    8
    Rep Power
    0

    Post timer

    i want to print there messages put i want it to print the first one right away wait 5 seconds to print the second and then 3 seonds after the 2nd message to start the third so how do i time it like that

    code
    ------------------------------------------
    public static void main (String args[]){
    System.out.println("debugging minecraft...");
    System.out.println("debugging minecraft...");

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,771
    Blog Entries
    7
    Rep Power
    21

    Default Re: timer

    Quote Originally Posted by Crowdy199 View Post
    i want to print there messages put i want it to print the first one right away wait 5 seconds to print the second and then 3 seonds after the 2nd message to start the third so how do i time it like that
    Have a look at the java.util.Timer class.

    kind regards,

    Jos
    awinston likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: timer

    The answer is in your title: Timer
    Last edited by awinston; 08-06-2012 at 03:12 AM.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  4. #4
    Crowdy199 is offline Member
    Join Date
    Jun 2012
    Posts
    8
    Rep Power
    0

    Default Re: timer

    one oher question how do i start an .exe file with java code and thanks alot guys for the help

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: timer

    Quote Originally Posted by awinston View Post
    The answer is in your title: Timer
    I politely disagree. Your link is for a Swing Timer or javax.swing.Timer, and this will only work if a Swing event loop is running, usually by displaying a Swing top-level window. Since the original poster is asking about printing out Strings on the console with a Timer, not in a Swing GUI, better is to use a java.util.Timer as Jos mentions above.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: timer

    Quote Originally Posted by Crowdy199 View Post
    one oher question how do i start an .exe file with java code and thanks alot guys for the help
    To do this you would use the ProcessBuilder class to create a Process. Please have a look at the API that I've linked to in the previous line.

  7. #7
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: timer

    Quote Originally Posted by Fubarable View Post
    I politely disagree. Your link is for a Swing Timer or javax.swing.Timer, and this will only work if a Swing event loop is running, usually by displaying a Swing top-level window. Since the original poster is asking about printing out Strings on the console with a Timer, not in a Swing GUI, better is to use a java.util.Timer as Jos mentions above.
    Thank you, my mistake. My google search brought up both and I wrongly assumed that the first result would be java.util.Timer. Should have double-checked. I changed the link.
    Fubarable likes this.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

Similar Threads

  1. Timer And Timer Task
    By Ashish_jain in forum New To Java
    Replies: 3
    Last Post: 06-22-2011, 10:41 AM
  2. Stopping a Timer from Inside the timer
    By krishnan in forum Java Applets
    Replies: 2
    Last Post: 10-05-2010, 12:15 AM
  3. Timer
    By Learning Java in forum New To Java
    Replies: 3
    Last Post: 08-11-2010, 01:18 PM
  4. Timer
    By barts2108 in forum New To Java
    Replies: 4
    Last Post: 06-08-2010, 07:17 PM
  5. Replies: 0
    Last Post: 04-04-2008, 03:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •