Last active
October 14, 2015 12:34
-
-
Save wintersteiger/26b6d94a27c5f0ea6bdc to your computer and use it in GitHub Desktop.
Test input for https://github.com/Z3Prover/z3/issues/245
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import com.microsoft.z3.*; | |
public class Gh245 | |
{ | |
public Gh245() { } | |
public static void main(String[] args) | |
{ | |
int num_threads = 64; | |
final Object m_lock = new Object(); | |
for (int i = 0; i < num_threads; i++) { | |
Thread thread = new Thread() { | |
@Override public void run() { | |
Context ctx = null; | |
synchronized (m_lock) { | |
ctx = new Context(); | |
} | |
BoolExpr x = ctx.mkBoolConst("x"); | |
BoolExpr y = ctx.mkBoolConst("y"); | |
Random rng = new Random(); | |
int end = rng.nextInt(20000); | |
for (int j = 0; j < end; j++) { | |
switch (rng.nextInt(4)) { | |
case 0: x = ctx.mkAnd(x, y); break; | |
case 1: y = ctx.mkOr(x, y); break; | |
case 2: x = ctx.mkBoolConst(ctx.mkSymbol(rng.nextInt(256))); break; | |
case 3: y = ctx.mkXor(y, x); break; | |
default: break; | |
} | |
} | |
System.gc(); | |
Runtime.getRuntime().runFinalization(); | |
} | |
}; | |
thread.start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment