Results 1 to 3 of 3
  1. #1
    Arnold is offline Member
    Join Date
    Oct 2009
    Location
    Rotterdam
    Posts
    52
    Rep Power
    0

    Post How do you create a simple timer?

    So basically i would like to see something like this:
    Java Code:
    class Waiting {
      public static void main(String args[]) {
        System.out,println("I'll wait");
        // Wait 5 seconds before proceed;
        System.out.println("I waited five seconds");
      }
    }
    Is there any way to do this in Java?

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Read the API specs for Thread.wait.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You can implement timers in two different ways. As r035198x says use of threads is one of the solution. In UI like Swing in Java you can use Swing timer as well. But in your case the Thread.sleep is enough, no need to involve with Swing timer. Just an info to our OP.

Similar Threads

  1. dont let me create simple class
    By itaipee in forum New To Java
    Replies: 5
    Last Post: 01-11-2009, 12:07 PM
  2. How Can I Create a Simple Grid with a GridLayout?
    By geeeeky.girl in forum AWT / Swing
    Replies: 7
    Last Post: 01-07-2009, 04:31 AM
  3. beginner to create a countup timer
    By taishan in forum New To Java
    Replies: 3
    Last Post: 11-13-2008, 06:46 AM
  4. How to create a simple deadlock
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 07:36 PM
  5. Simple timer
    By im-not-alive in forum New To Java
    Replies: 1
    Last Post: 01-20-2008, 10:04 PM

Posting Permissions

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