<commit_before>package rakka;

import com.sun.jdi.Bootstrap;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.VirtualMachineManager;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.LaunchingConnector;
import com.sun.jdi.connect.VMStartException;
import com.sun.jdi.event.Event;
import com.sun.jdi.event.EventQueue;
import com.sun.jdi.event.EventSet;
import com.sun.jdi.event.VMDisconnectEvent;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

/**
 * Created by lidavidm on 2/10/16.
 */
public class RakkaMain {
    public static void main(String[] args) {
        // For reference: http://stackoverflow.com/questions/21654255
        VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
        LaunchingConnector connector = vmm.defaultConnector();
        Map<String, Connector.Argument> arguments = connector.defaultArguments();
        arguments.get("main").setValue("reki.RekiShim");
        arguments.get("options").setValue("-cp /home/lidavidm/Code/cornell/cs6360/server_prototype/out/production/server_prototype");
        try {
            VirtualMachine vm = connector.launch(arguments);
            vm.resume();

//            EventQueue events = vm.eventQueue();
//            EVENT_LOOP: while (true) {
//                EventSet e = events.remove();
//                for (Event event : e) {
//                    System.out.println(event);
//                    if (event instanceof VMDisconnectEvent) {
//                        break EVENT_LOOP;
//                    }
//                }
//            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(vm.process().getInputStream()));
            reader.lines().forEach(System.out::println);

            BufferedReader stderr = new BufferedReader(new InputStreamReader(vm.process().getErrorStream()));
            stderr.lines().forEach(System.out::println);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IllegalConnectorArgumentsException e) {
            e.printStackTrace();
        } catch (VMStartException e) {
            e.printStackTrace();
        }
    }
}<commit_msg>Move child VM IO processing to threads<commit_after>package rakka;

import com.sun.jdi.Bootstrap;
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.VirtualMachineManager;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.LaunchingConnector;
import com.sun.jdi.connect.VMStartException;
import com.sun.jdi.event.Event;
import com.sun.jdi.event.EventQueue;
import com.sun.jdi.event.EventSet;
import com.sun.jdi.event.VMDisconnectEvent;

import java.io.*;
import java.util.Map;

/**
 * Created by lidavidm on 2/10/16.
 */
public class RakkaMain {
    static class StreamHandlerThread extends Thread {
        private final BufferedReader reader;
        private final PrintStream writer;

        public StreamHandlerThread(InputStream is, OutputStream os) {
            reader = new BufferedReader(new InputStreamReader(is));
            writer = new PrintStream(os);
        }

        @Override
        public void run() {
            try {
                String line = "";
                while ((line = reader.readLine()) != null) {
                    writer.println(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        // For reference: http://stackoverflow.com/questions/21654255
        VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
        LaunchingConnector connector = vmm.defaultConnector();
        Map<String, Connector.Argument> arguments = connector.defaultArguments();
        arguments.get("main").setValue("reki.RekiShim");
        arguments.get("options").setValue("-cp /home/lidavidm/Code/cornell/cs6360/server_prototype/out/production/server_prototype");
        try {
            VirtualMachine vm = connector.launch(arguments);
            vm.resume();

            new StreamHandlerThread(vm.process().getInputStream(), System.out).run();
            new StreamHandlerThread(vm.process().getErrorStream(), System.err).run();
            EventQueue events = vm.eventQueue();

            EVENT_LOOP:
            while (true) {
                EventSet e = events.remove();
                for (Event event : e) {
                    if (event instanceof VMDisconnectEvent) {
                        break EVENT_LOOP;
                    }

                    System.out.println(event);
                }
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IllegalConnectorArgumentsException e) {
            e.printStackTrace();
        } catch (VMStartException e) {
            e.printStackTrace();
        }
    }
}
{'fraction_non_alphanumeric': 0.11254648659228812, 'fraction_numerical': 0.006654922685457036, 'mean_word_length': 2.3203378817413904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6948186', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1366, 'n_words': 263}