DmtcpJavaDemo.java
// DmtcpJavaDemo.java
import java.io.IOException;
import java.io.PrintWriter;
public class DmtcpJavaDemo
{
public static void main(String[] args) throws IOException
{
// Get user name from the system
String user = System.getProperty("user.name");
try
{
String fname = "/scratch/" + user + "/DmtcpJavaDemo.txt";
System.out.println("Writing output to: " + fname);
PrintWriter outfs = new PrintWriter(fname);
int i=0;
while (i < 180) // 3 minutes
{
System.out.print(i);
System.out.print("\t");
System.out.flush();
outfs.write(Integer.toString(i));
outfs.write("\t");
outfs.flush();
i++;
try
{
// thread to sleep for 1000 milliseconds
Thread.sleep(1000);
}
catch (Exception e)
{
System.err.println(e);
}
}
}
catch (IOException e)
{
System.err.println("ERROR: WRITING FILE " + e.toString());
}
}
}
To compile DmtcpJavaDemo.java, use the following commands:
javac DmtcpJavaDemo.java