Results 1 to 3 of 3

Thread: Make Java Pause

  1. #1
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Make Java Pause

    Hey all. I am not sure how "advanced" my question is, so I apologise the admins if this thread should be in the Advanced section.

    Anyway. I have a robot and its runs Javelin micro controller, so I program my robot in Java. I am running this simple code:

    Java Code:
    for (int i=0;i<10;i++)
     System.out.println(i);
    Anyway, I would like to know if there is such way to pause the code for half a second or something like that?

    Thanks
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

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

    Default

    Read about the static method Thread.sleep( ... ).

    kind regards,

    Jos

  3. #3
    thomasdevos's Avatar
    thomasdevos is offline Member
    Join Date
    Feb 2010
    Posts
    19
    Rep Power
    0

    Default

    hi FlyNn,
    i guess blew code can help you. good luck:
    Java Code:
    public class TheThread {
    public static void main(String[] args) {
    	for (int i=0;i<10;i++){
    		 System.out.println(i);
    		 try {
    			Thread.sleep(500);
    		} catch (InterruptedException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		 
    	}
    }
    }
    i hold 7 years develop exp. now i start a thread to share my knowlege about a j2ee project. welcome to participate.Study Java Through Real Java Project

Similar Threads

  1. Pause and Continue Long Cycles
    By pedro123 in forum Threads and Synchronization
    Replies: 2
    Last Post: 07-28-2009, 07:47 AM
  2. How to stop/pause running third party exe?
    By 2bGeek in forum AWT / Swing
    Replies: 3
    Last Post: 02-28-2009, 07:26 AM
  3. Replies: 1
    Last Post: 12-07-2008, 05:50 PM
  4. pause until JFrame is closed.
    By Tamu in forum Advanced Java
    Replies: 8
    Last Post: 11-30-2008, 09:46 PM
  5. Help with Pause
    By trill in forum Java Applets
    Replies: 2
    Last Post: 09-28-2007, 08:50 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
  •