Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners sleep method in thread java program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Naulej kumar
sleep method in thread java program
1 Answer(s)      2 years and 3 months ago
Posted in : Java Beginners


How can we use sleep method in thread ?


Advertisement
View Answers

June 11, 2012 at 7:04 PM


public class test {
    public static void main(String [] args){
                  String str[] ={"Delhi","Bihar","Goa"
                                 ,"Pune" ,"Mumbai"};

                  for (int i = 0; i <str.length; i++) {
                    try {
                     System.out.println(str[i]);
                     Thread.sleep(5000);

                 } catch (InterruptedException e) {
                }
              }
            } 
          }

Output

Delhi
Bihar
Goa
Pune
mumbai

Description:- In this thread example ,we have used sleep method. we are passing some interval to the sleep method .After that interval thread will awake.



Related Tutorials/Questions & Answers:
sleep method in thread java program
sleep method in thread java program  How can we use sleep method... Description:- In this thread example ,we have used sleep method. we are passing some interval to the sleep method .After that interval thread will awake
Java Thread : sleep() method
Java Thread : sleep() method In this section we are going to describe sleep() method with example in java thread. sleep() method : Suppose you want to stop your thread for a specific time period, you can use sleep() method
Advertisements
Java Sleep Thread
Java Thread sleep() is a static method. It sleeps the thread for the given time in milliseconds. It is used to delay the thread. It is used in Applet or GUI programming for animation Java Sleep Thread Example public class
example of sleep and wait method
example of sleep and wait method  write a program to use the sleep and wait method of thread class
java thread program
java thread program  write a java program to find out the current running thread in a java program   public class RunningThreads{ public...() + ":" + group.getClass()+"]"); int count = group.activeCount(); Thread[] threads
java thread program
java thread program  write a java program to find out all the current running thread in a java program   public class RunningThreads...() + ":" + group.getClass()+"]"); int count = group.activeCount(); Thread[] threads
Java Thread : toString() method
Java Thread : toString() method In this section we are going to describe toString() method with example in java thread. toString() method : If you want... and thread group. Example :In this example we are using toString() method
Java Thread : setDaemon() method
Java Thread : setDaemon() method In this section we are going to describe setDaemon() method with example in java thread. Daemon Thread  : In Java.... public final void setDaemon(boolean on) : This method sets user thread either
Java Thread : isAlive() method
Java Thread : isAlive() method In this tutorial you will learn how to use isAlive() method in java thread. isAlive() method : When you are running many... of your thread dead. This can be checked by using method Thread.isAlive(). boolean
Java Thread : isDaemon() method
Java Thread : isDaemon() method In this section we are going to describe isDaemon() method with example in java thread. Daemon Thread  : In Java Thread, daemon threads are used to perform services for user threads. You can
Java Thread : yield() method
Java Thread : yield() method In this section we are going to describe yield() method with example in java thread. yield() Method: When you want to stop...() method of Thread. public static void yield() - This method pauses
Java Thread : run() method
Java Thread : run() method In this section we are going to describe run() method with example in java thread. Thread run() : All the execution code...() : By extending the Thread class, run() method is overridden and put all
Java Thread : stop() method
Java Thread : stop() method In this section we are going to describe stop() method with example in java thread. stop() method : Java thread provides method stop to stop any running thread. It is deprecated  as it causes
PHP Sleep Wakeup Method
purpose. The serialize method checks every program whether it has a magic method __sleep or not. If so, then the function execute that method prior to any other... that the object may have. PHP Sleep and Wakeup Method Example: <?php
Thread method
Thread method  What is the purpose of the wait(), notify(), and notifyAll() methods
Java thread
Java thread  What is the difference between wait() and sleep method
Java Method Synchronized
Java Method Synchronized       The Java language Program supports multi threads. The synchronized is a keyword used in Java ensures that only one Java thread execute an object's
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
I want only one method goes to sleep but both method goes to sleep together
I want only one method goes to sleep but both method goes to sleep... want like a sleep() or any other method should be invoked between User's turn and Computer's turn. But when i call Sleep() before cpuPlay() method or after
I want only one method goes to sleep but both method goes to sleep together
I want only one method goes to sleep but both method goes to sleep... want like a sleep() or any other method should be invoked between User's turn and Computer's turn. But when i call Sleep() before cpuPlay() method or after
Java thread state
Java thread state  Difference between sleep and suspend
Java Exception Thread
independently in program. Method in Object  and Thread Class... to Overcome this Thread Exception in Java Program In the preceding code, we... Java Exception Thread     
Method overloading in java program
Method overloading in java program  How can we use method overloading in java program?   Method overloading:?In method overloading methods have same name but different type of parameters. Here is an example of method
java program on recursive method
java program on recursive method  in how many ways can you make change for one dollar(100 cents) using pennies(1-cent coins), nickels(5 cents), dimes(10 cents),and quarter(25 cents)? the coins must add up to the exact total
thread program for calculator implementation
thread program for calculator implementation  Hi i'm prem i need calculator progrm in java that are implemented by Thread interface.....pls strong text
Java thread
Java thread  What invokes a thread's run() method
Java Thread Context
classloader to set a thread using Thread.setContextClassLoader() method... Thread Context       The Thread Context is required by the current thread from the group
Java Thread setName() Example
Java Thread setName() Example In this section we are going to describe setName() method with example in java thread. Thread setName() :  Suppose,  you want to change name of your thread so for that java thread provides
Advertisements
 

 

 

DMCA.com