Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 1&1 Internet AG, https://github.com/1and1/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package net.oneandone.jasmin.main;
Helper class for Runner
public class Client extends Thread {
    private final Engine engine;
    private final List<Stringpaths;
    private final int requests;
    private final boolean random;
    private final boolean lastModified;
    private Exception exception;
    public Client(Engine engineList<Stringpathsint requestsboolean randomboolean lastModified) {
        this. = engine;
        this. = paths;
        this. = requests;
        this. = random;
        this. = lastModified;
        this. = null;
    }
    @Override
    public void run() {
        try {
            doRun();
        } catch (Exception e) {
             = e;
        }
    }
    public void doRun() throws IOException {
        String path;
        for (int i = 0; i < i++) {
            if () {
                path = .get(..nextInt(.size()));
            } else {
                path = .get(i % .size());
            }
            if ( && ..nextBoolean()) {
                .getLastModified(path);
            } else {
                get(path);
            }
        }
    }
    public void get(String paththrows IOException {
        long started;
        String str;
        started = System.currentTimeMillis();
        try {
            str = .process(path);
            ..info(path + ": " + str.length() + " chars, " + (System.currentTimeMillis() - started) + " ms");
        } catch (IOException e) {
            ..error(pathe);
            throw e;
        }
    }
    public void finish() throws Exception {
        join();
        if ( != null) {
            throw ;
        }
    }
New to GrepCode? Check out our FAQ X