Solved

sleeping?

Posted on 1998-02-19
1
302 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaFX TableView not displaying correctly 3 150
Facing this issue for maven proxy setting 2 43
Java class and jar 3 58
Html split(text) 2 46
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
Suggested Courses

739 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