Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > about interrupt...

Reply
Thread Tools

about interrupt...

 
 
Kyung won Cheon
Guest
Posts: n/a
 
      01-16-2009
* Test.java

import java.io.FileOutputStream;

public class Test
{
public static void main(String[] args) throws Exception
{
Runtime.getRuntime().addShutdownHook(new Thread()
{
public void run()
{
try {
new FileOutputStream("shutdown.log").close();
} catch (Exception ioe) {
}
}
}
);
System.out.println("sleeping...");
Thread.sleep(100000);
}
}

* test.rb

trap('INT') { File.open('shutdown.log', 'w').close }
puts 'sleeping...'
sleep(100)

#----------------------------------------------------------
# I using windows XP
# (ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32])
#
# In Java,
# Ctrl+C and click [x] button of command window are ok!!
# In Ruby
# Only Ctrl+C is ok!!
#
# Help Me!!
#----------------------------------------------------------
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments