Project

General

Profile

Download (1.22 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2015 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.taxeditor.httpinvoker;
11

    
12
/**
13
 * @author cmathew
14
 * @date 16 Oct 2015
15
 *
16
 */
17
public abstract class TestThread extends Thread {
18
    Throwable throwable;
19
    boolean isBlocked = false;
20

    
21
    public TestThread() {
22

    
23
    }
24

    
25
    public TestThread(boolean blocking) {
26
        isBlocked = blocking;
27
    }
28
    /**
29
     * @return the throwable
30
     */
31
    public Throwable getThrowable() {
32
        return throwable;
33
    }
34

    
35
    /**
36
     * @param throwable the throwable to set
37
     */
38
    public void setThrowable(Throwable throwable) {
39
        this.throwable = throwable;
40
    }
41

    
42
    public void unblock() {
43
        isBlocked = false;
44
    }
45

    
46
    @Override
47
    public final void run() {
48
        try {
49
            while(isBlocked) {};
50
            doRun();
51
        } catch(Exception ex) {
52
            throwable = ex;
53
        } catch(AssertionError ae) {
54
            throwable = ae;
55
        }
56
    }
57

    
58
    public abstract void doRun() throws Exception, AssertionError;
59

    
60
}
(8-8/9)