Skip to content

Problem when executing with sleep in a script  #7

@yogeshjawale

Description

@yogeshjawale

Hi,

I don't know if this is an issue with this script, but when you execute a shell script with
sleep {sleep_time} in it, then the timeout does not terminate the script/program.

I am attaching the code which i tried to run below,

!/bin/bash

i=1;
while [ $i -lt 10000000 ]
do
echo "$i second" ;
i=$[$i+1];
sleep 1;
done

I also tried using it with java program using threads but same result with that as well.

Java code below,

import java.util.;
import java.text.
;
import java.math.;
import java.io.
;
public class TestClass {
public static void main(String[] args) {
int i=1;
try {
while(true)
{
System.out.println(i++);
//thread to sleep for the specified number of milliseconds
Thread.sleep(1000);
}
} catch ( java.lang.InterruptedException ie) {
System.out.println(ie);
}
}
}

Please help me out here. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions