Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sleeping?

Posted on 1998-02-19
1
Medium Priority
?
305 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 100 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

596 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