Solved

sleeping?

Posted on 1998-02-19
1
303 Views
Last Modified: 2010-04-16
How do you tell a Java application to sleep? For example I am talking to a serial device that need at least 300ms between commands?

I found a sleep method for a thread but I don't have a thread
0
Comment
Question by:micah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 1233165
Of course you have a Thread, you are running aren't you?

import java.lang.Thread
;
public class Source1
{
      public static void main (String args[])
      {
            System.out.println("Hello World!!");
            Thread cT = Thread.currentThread();
            System.out.println("Starting sleep period");
            try{
                  cT.sleep(1000);
            }
            catch(InterruptedException e){
                  System.out.println("Leave me alone!");
            }
            System.out.println("Waking up");
      }
}
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question