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
Solved

sleeping?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 104
ForLoop Example 3 52
Windows 10 IE Certificate Issue 10 51
HashTable highest marks enumeration alternative 9 42
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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

789 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