List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:com.zytan.sdpn.peer.SDPFullPeer.java
public static void main(String[] args) { boolean active = true; if (args.length != 0) { SDPFullPeer peer = null;/*from w w w . j av a 2s.c o m*/ if (args.length == 3) { //args[0]=file peer configuration args[1]=key peer = new SDPFullPeer(args[0], args[1]); } else if (args.length == 5) { //args[0]=file peer configuration args[1]=key args[2]=peer name args[3]=peer port peer = new SDPFullPeer(args[0], args[1], args[2], new Integer(args[3])); } for (int i = 0; i < args.length; i++) { /* * join to bootstrapPeer */ if (args[i].equals("-j")) { peer.joinToBootstrapPeer(); } /* * request public address from SBC */ else if (args[i].equals("-s")) { peer.contactSBC(); } /* * join to bootstrapPeer, wait and send ping message to random peer */ else if (args[i].equals("-jp")) { peer.joinToBootstrapPeer(); //wait for 3 seconds try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } peer.pingToPeerRandomFromList(); } /* * join to bootstrapPeer, wait and send ping message to random peer recursively */ else if (args[i].equals("-jr")) { peer.joinToBootstrapPeer(); while (active) { //wait for 15 seconds try { Thread.sleep(15000); } catch (InterruptedException e) { e.printStackTrace(); } //ping bootstrap to keep live peer.pingToPeer(peer.peerConfig.bootstrap_peer); //call peer api //peer.callPeerAPI("lightOn"); } } else if (args[i].equals("-p")) { peer.pingToPeer(args[5]); } else if (args[i].equals("-sd")) { peer.contactSBC(); try { Thread.sleep(7000); } catch (InterruptedException e) { e.printStackTrace(); } peer.disconnectGWP(); } /* * contact SBC, wait, join to bootstrapPeer, wait and send ping message to random peer recursively */ else if (args[i].equals("-a")) { peer.contactSBC(); try { Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } peer.joinToBootstrapPeer(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } peer.pingToPeerRandomFromList(); } } } }
From source file:net.yacy.crawler.data.CacheTest.java
/** * Run a stress test on the Cache/*from w ww. j a va 2 s . c o m*/ * * @param args * main arguments * @throws IOException * when a error occurred */ public static void main(final String args[]) throws IOException { System.out.println("Stress test on Cache"); /* * Set the root log level to WARNING to prevent filling the console with * too many information log messages */ LogManager.getLogManager().readConfiguration( new ByteArrayInputStream(".level=WARNING".getBytes(StandardCharsets.ISO_8859_1))); /* Main control parameters. Modify values for different scenarios. */ /* Number of concurrent test tasks */ final int threads = 50; /* Number of steps in each task */ final int steps = 10; /* Number of test URLs in each task */ final int urlsPerThread = 5; /* Size of the generated test content */ final int contentSize = Math.max(Cache.DEFAULT_COMPRESSOR_BUFFER_SIZE + 1, Cache.DEFAULT_BACKEND_BUFFER_SIZE + 1) / urlsPerThread; /* Cache maximum size */ final long cacheMaxSize = Math.min(1024 * 1024 * 1024, ((long) contentSize) * 10 * urlsPerThread); /* Sleep time between each cache operation */ final long sleepTime = 0; /* Maximum waiting time (in ms) for acquiring a synchronization lock */ final long lockTimeout = 2000; /* The backend compression level */ final int compressionLevel = Deflater.BEST_COMPRESSION; Cache.init(new File(System.getProperty("java.io.tmpdir") + File.separator + "yacyTestCache"), "peerSalt", cacheMaxSize, lockTimeout, compressionLevel); Cache.clear(); System.out.println("Cache initialized with a maximum size of " + cacheMaxSize + " bytes."); try { System.out.println("Starting " + threads + " threads ..."); long time = System.nanoTime(); List<CacheAccessTask> tasks = new ArrayList<>(); for (int count = 0; count < threads; count++) { List<DigestURL> urls = new ArrayList<>(); for (int i = 0; i < urlsPerThread; i++) { urls.add(new DigestURL("http://yacy.net/" + i + "/" + count)); } CacheAccessTask thread = new CacheAccessTask(urls, steps, contentSize, sleepTime); thread.start(); tasks.add(thread); } /* Wait for tasks termination */ for (CacheAccessTask task : tasks) { try { task.join(); } catch (InterruptedException e) { e.printStackTrace(); } } /* * Check consistency : cache should be empty when all tasks have * terminated without error */ Cache.commit(); long docCount = Cache.getActualCacheDocCount(); if (docCount > 0) { System.out.println("Cache is not empty!!! Actual documents count : " + docCount); } System.out.println("All threads terminated in " + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - time) + "s. Computing statistics..."); long storeTime = 0; long maxStoreTime = 0; long getContentTime = 0; long maxGetContentTime = 0; int storeFailures = 0; long deleteTime = 0; long maxDeleteTime = 0; long totalSteps = 0; for (CacheAccessTask task : tasks) { storeTime += task.getStoreTime(); maxStoreTime = Math.max(task.getMaxStoreTime(), maxStoreTime); getContentTime += task.getGetContentTime(); maxGetContentTime = Math.max(task.getMaxGetContentTime(), maxGetContentTime); storeFailures += task.getStoreFailures(); deleteTime += task.getDeleteTime(); maxDeleteTime = Math.max(task.getMaxDeleteTime(), maxDeleteTime); totalSteps += task.getSteps(); } System.out.println("Cache.store() total time (ms) : " + TimeUnit.NANOSECONDS.toMillis(storeTime)); System.out.println("Cache.store() maximum time (ms) : " + TimeUnit.NANOSECONDS.toMillis(maxStoreTime)); System.out.println( "Cache.store() mean time (ms) : " + TimeUnit.NANOSECONDS.toMillis(storeTime / totalSteps)); System.out.println("Cache.store() failures : " + storeFailures); System.out.println(""); System.out.println( "Cache.getContent() total time (ms) : " + TimeUnit.NANOSECONDS.toMillis(getContentTime)); System.out.println( "Cache.getContent() maximum time (ms) : " + TimeUnit.NANOSECONDS.toMillis(maxGetContentTime)); System.out.println("Cache.getContent() mean time (ms) : " + TimeUnit.NANOSECONDS.toMillis(getContentTime / totalSteps)); System.out.println("Cache hits : " + Cache.getHits() + " total requests : " + Cache.getTotalRequests() + " ( hit rate : " + NumberFormat.getPercentInstance().format(Cache.getHitRate()) + " )"); System.out.println(""); System.out.println("Cache.delete() total time (ms) : " + TimeUnit.NANOSECONDS.toMillis(deleteTime)); System.out .println("Cache.delete() maximum time (ms) : " + TimeUnit.NANOSECONDS.toMillis(maxDeleteTime)); System.out.println( "Cache.delete() mean time (ms) : " + TimeUnit.NANOSECONDS.toMillis(deleteTime / totalSteps)); } finally { try { Cache.close(); } finally { /* Shutdown running threads */ ArrayStack.shutdownDeleteService(); try { Domains.close(); } finally { ConcurrentLog.shutdown(); } } } }
From source file:de.prozesskraft.pkraft.Startinstance.java
public static void main(String[] args) throws org.apache.commons.cli.ParseException, IOException { /*---------------------------- get options from ini-file/*from ww w . j a v a 2 s . c o m*/ ----------------------------*/ java.io.File inifile = new java.io.File(WhereAmI.getInstallDirectoryAbsolutePath(Startinstance.class) + "/" + "../etc/pkraft-startinstance.ini"); if (inifile.exists()) { try { ini = new Ini(inifile); } catch (InvalidFileFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { System.err.println("ini file does not exist: " + inifile.getAbsolutePath()); System.exit(1); } /*---------------------------- create boolean options ----------------------------*/ Option ohelp = new Option("help", "print this message"); Option ov = new Option("v", "prints version and build-date"); /*---------------------------- create argument options ----------------------------*/ Option obasedir = OptionBuilder.withArgName("DIR").hasArg() .withDescription("[optional, default .] base directory where instance shourd run.") // .isRequired() .create("basedir"); Option odefinition = OptionBuilder.withArgName("FILE").hasArg() .withDescription("[optional] definition file of the process you want to start an instance from.") // .isRequired() .create("definition"); Option onostart = OptionBuilder.withArgName("") // .hasArg() .withDescription( "[optional] oppresses the start of the instance. (only create the process-instance)") // .isRequired() .create("nostart"); Option opdomain = OptionBuilder.withArgName("STRING").hasArg() .withDescription("[optional] domain of the process (mandatory if you omit -definition)") // .isRequired() .create("pdomain"); Option opname = OptionBuilder.withArgName("STRING").hasArg().withDescription( "[optional] name of the process you want to start an instance from (mandatory if you omit -definition)") // .isRequired() .create("pname"); Option opversion = OptionBuilder.withArgName("STRING").hasArg().withDescription( "[optional] version of the process you want to start an instance from (mandatory if you omit -definition)") // .isRequired() .create("pversion"); Option ocommitfile = OptionBuilder.withArgName("KEY=FILE; FILE").hasArg() .withDescription("[optional] this file will be committed as file. omit KEY= if KEY==FILENAME.") // .isRequired() .create("commitfile"); Option ocommitvariable = OptionBuilder.withArgName("KEY=VALUE; VALUE").hasArg() .withDescription("[optional] this string will be committed as a variable. omit KEY= if KEY==VALUE") // .isRequired() .create("commitvariable"); Option ocommitfiledummy = OptionBuilder.withArgName("KEY=FILE; FILE").hasArg().withDescription( "[optional] use this parameter like --commitfile. the file will not be checked against the process interface and therefore allows to commit files which are not expected by the process definition. use this parameter only for test purposes e.g. to commit dummy output files for accelerated tests of complex processes or the like.") // .isRequired() .create("commitfiledummy"); Option ocommitvariabledummy = OptionBuilder.withArgName("KEY=VALUE; VALUE").hasArg().withDescription( "[optional] use this parameter like --commitvariable. the variable will not be checked against the process interface and therefore allows to commit variables which are not expected by the process definition. use this parameter only for test purposes e.g. to commit dummy output variables for accelerated tests of complex processes or the like.") // .isRequired() .create("commitvariabledummy"); /*---------------------------- create options object ----------------------------*/ Options options = new Options(); options.addOption(ohelp); options.addOption(ov); options.addOption(obasedir); options.addOption(odefinition); options.addOption(onostart); options.addOption(opname); options.addOption(opversion); options.addOption(ocommitfile); options.addOption(ocommitvariable); options.addOption(ocommitfiledummy); options.addOption(ocommitvariabledummy); /*---------------------------- create the parser ----------------------------*/ CommandLineParser parser = new GnuParser(); // parse the command line arguments commandline = parser.parse(options, args); /*---------------------------- usage/help ----------------------------*/ if (commandline.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("startinstance", options); System.exit(0); } if (commandline.hasOption("v")) { System.out.println("author: alexander.vogel@caegroup.de"); System.out.println("version: [% version %]"); System.out.println("date: [% date %]"); System.exit(0); } /*---------------------------- ueberpruefen ob eine schlechte kombination von parametern angegeben wurde ----------------------------*/ if (!(commandline.hasOption("definition")) && (!(commandline.hasOption("pname")) || !(commandline.hasOption("pversion")) || !(commandline.hasOption("pdomain")))) { System.err.println("option -definition or the options -pname & -pversion & -pdomain are mandatory"); exiter(); } if ((commandline.hasOption("definition") && ((commandline.hasOption("pversion")) || (commandline.hasOption("pname")) || (commandline.hasOption("pdomain"))))) { System.err.println("you must not use option -definition with -pversion or -pname or -pdomain"); exiter(); } /*---------------------------- die lizenz ueberpruefen und ggf abbrechen ----------------------------*/ // check for valid license ArrayList<String> allPortAtHost = new ArrayList<String>(); allPortAtHost.add(ini.get("license-server", "license-server-1")); allPortAtHost.add(ini.get("license-server", "license-server-2")); allPortAtHost.add(ini.get("license-server", "license-server-3")); MyLicense lic = new MyLicense(allPortAtHost, "1", "user-edition", "0.1"); // lizenz-logging ausgeben for (String actLine : (ArrayList<String>) lic.getLog()) { System.err.println(actLine); } // abbruch, wenn lizenz nicht valide if (!lic.isValid()) { System.exit(1); } /*---------------------------- die eigentliche business logic ----------------------------*/ Process p1 = new Process(); String pathToDefinition = ""; if (commandline.hasOption("definition")) { pathToDefinition = commandline.getOptionValue("definition"); } else if (commandline.hasOption("pname") && commandline.hasOption("pversion") && commandline.hasOption("pdomain")) { pathToDefinition.replaceAll("/+$", ""); pathToDefinition = ini.get("process", "domain-installation-directory") + "/" + commandline.getOptionValue("pdomain") + "/" + commandline.getOptionValue("pname") + "/" + commandline.getOptionValue("pversion") + "/process.xml"; } else { System.err.println("option -definition or the options -pname & -pversion & -pdomain are mandatory"); exiter(); } // check ob das ermittelte oder uebergebene xml-file ueberhaupt existiert java.io.File xmlDefinition = new java.io.File(pathToDefinition); if (!(xmlDefinition.exists()) || !(xmlDefinition.isFile())) { System.err.println("process definition does not exist: " + pathToDefinition); exiter(); } p1.setInfilexml(xmlDefinition.getCanonicalPath()); Process p2 = null; try { p2 = p1.readXml(); } catch (JAXBException e1) { System.err.println(e1.getMessage()); } // das processBinary vorneweg schon mal erstellen, da es sein kann das das committen laenger dauert und ein pradar-attend den neuen prozess schon mal aufnehmen will // root-verzeichnis erstellen if (commandline.hasOption("basedir")) { p2.setBaseDir(commandline.getOptionValue("basedir")); } p2.makeRootdir(); // den pfad fuers binary setzen p2.setOutfilebinary(p2.getRootdir() + "/process.pmb"); System.err.println("info: writing process instance " + p2.getOutfilebinary()); // binary schreiben p2.writeBinary(); // step, an den die commits gehen, soll 'root' sein. Step stepRoot = p2.getRootStep(); // committen von files (ueber einen glob) if (commandline.hasOption("commitfile")) { for (String actOptionCommitfile : commandline.getOptionValues("commitfile")) { String[] parts = actOptionCommitfile.split("="); File userFile = new File(); if (parts.length == 1) { userFile.setKey(new java.io.File(parts[0]).getName()); userFile.setGlob(parts[0]); } else if (parts.length == 2) { userFile.setKey(parts[0]); userFile.setGlob(parts[1]); } else { System.err.println("error in option -commitfile " + actOptionCommitfile); exiter(); } // die auf der kommandozeile uebergebenen Informationen sollen in die vorhandenen commits im rootStep gemappt werden // alle vorhandenen commits in step root durchgehen und dem passenden file zuordnen for (Commit actCommit : stepRoot.getCommit()) { // alle files des aktuellen commits for (File actFile : actCommit.getFile()) { if (actFile.getKey().equals(userFile.getKey())) { // wenn actFile schon ein valider eintrag ist, dann soll ein klon befuellt werden if (actFile.getGlob() != null) { // wenn die maximale erlaubte anzahl noch nicht erreicht ist if (actCommit.getFile(actFile.getKey()).size() < actFile.getMaxoccur()) { File newFile = actFile.clone(); newFile.setGlob(userFile.getGlob()); System.err.println("entering file into commit '" + actCommit.getName() + "' (" + newFile.getKey() + "=" + newFile.getGlob() + ")"); actCommit.addFile(newFile); break; } else { System.err.println("fatal: you only may commit " + actFile.getMaxoccur() + " " + actFile.getKey() + "-files into commit " + actCommit.getName()); exiter(); } } // ansonsten das bereits vorhandene file im commit mit den daten befuellen else { actFile.setGlob(userFile.getGlob()); actFile.setGlobdir(p2.getBaseDir()); System.err.println("entering file into commit '" + actCommit.getName() + "' (" + actFile.getKey() + "=" + actFile.getGlob() + ")"); break; } } } } } } // committen von files (ueber einen glob) if (commandline.hasOption("commitfiledummy")) { // diese files werden nicht in bestehende commits der prozessdefinition eingetragen, sondern in ein spezielles commit Commit commitFiledummy = new Commit(); commitFiledummy.setName("fileDummy"); stepRoot.addCommit(commitFiledummy); for (String actOptionCommitfiledummy : commandline.getOptionValues("commitfiledummy")) { String[] parts = actOptionCommitfiledummy.split("="); File userFile = new File(); commitFiledummy.addFile(userFile); if (parts.length == 1) { userFile.setKey(new java.io.File(parts[0]).getName()); userFile.setGlob(parts[0]); } else if (parts.length == 2) { userFile.setKey(parts[0]); userFile.setGlob(parts[1]); } else { System.err.println("error in option -commitfiledummy " + actOptionCommitfiledummy); exiter(); } userFile.setGlobdir(p2.getBaseDir()); System.err.println("entering (dummy-)file into commit '" + commitFiledummy.getName() + "' (" + userFile.getKey() + "=" + userFile.getGlob() + ")"); } } if (commandline.hasOption("commitvariable")) { for (String actOptionCommitvariable : commandline.getOptionValues("commitvariable")) { if (actOptionCommitvariable.matches(".+=.+")) { String[] parts = actOptionCommitvariable.split("="); Variable userVariable = new Variable(); if (parts.length == 1) { userVariable.setKey("default"); userVariable.setValue(parts[0]); } else if (parts.length == 2) { userVariable.setKey(parts[0]); userVariable.setValue(parts[1]); } else { System.err.println("error in option -commitvariable"); exiter(); } // commit.addVariable(variable); // die auf der kommandozeile uebergebenen Informationen sollen in die vorhandenen commits im rootStep gemappt werden // alle vorhandenen commits in step root durchgehen und dem passenden file zuordnen for (Commit actCommit : stepRoot.getCommit()) { // alle files des aktuellen commits for (Variable actVariable : actCommit.getVariable()) { if (actVariable.getKey().equals(userVariable.getKey())) { // wenn actFile schon ein valider eintrag ist, dann soll ein klon befuellt werden if (actVariable.getGlob() != null) { // wenn die maximale erlaubte anzahl noch nicht erreicht ist if (actCommit.getVariable(actVariable.getKey()).size() < actVariable .getMaxoccur()) { Variable newVariable = actVariable.clone(); newVariable.setValue(userVariable.getValue()); System.err.println("entering variable into commit '" + actCommit.getName() + "' (" + newVariable.getKey() + "=" + newVariable.getValue() + ")"); actCommit.addVariable(newVariable); break; } else { System.err.println("fatal: you only may commit " + actVariable.getMaxoccur() + " " + actVariable.getKey() + "-variable(s) into commit " + actCommit.getName()); exiter(); } } // ansonsten das bereits vorhandene file im commit mit den daten befuellen else { actVariable.setValue(userVariable.getValue()); System.err.println("entering variable into commit '" + actCommit.getName() + "' (" + actVariable.getKey() + "=" + actVariable.getValue() + ")"); break; } } } } } else { System.err.println("-commitvariable " + actOptionCommitvariable + " does not match pattern \"NAME=VALUE\"."); exiter(); } } } if (commandline.hasOption("commitvariabledummy")) { // diese files werden nicht in bestehende commits der prozessdefinition eingetragen, sondern in ein spezielles commit Commit commitVariabledummy = new Commit(); commitVariabledummy.setName("variableDummy"); stepRoot.addCommit(commitVariabledummy); for (String actOptionCommitvariabledummy : commandline.getOptionValues("commitvariabledummy")) { String[] parts = actOptionCommitvariabledummy.split("="); Variable userVariable = new Variable(); commitVariabledummy.addVariable(userVariable); if (parts.length == 1) { userVariable.setKey(parts[0]); userVariable.setValue(parts[0]); } else if (parts.length == 2) { userVariable.setKey(parts[0]); userVariable.setValue(parts[1]); } else { System.err.println("error in option -commitvariabledummy"); exiter(); } System.err.println("entering variable into commit '" + commitVariabledummy.getName() + "' (" + userVariable.getKey() + "=" + userVariable.getValue() + ")"); } } // if (commandline.hasOption("basedir")) // { // p2.setBaseDir(commandline.getOptionValue("basedir")); // } // commit.doIt(); stepRoot.commit(); // root-verzeichnis erstellen p2.makeRootdir(); // den pfad fuers binary setzen // p2.setOutfilebinary(p2.getRootdir() + "/process.pmb"); System.err.println("info: writing process instance " + p2.getOutfilebinary()); // binary schreiben p2.writeBinary(); try { Thread.sleep(1500, 0); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Runtime.getRuntime().exec("process-manager -help"); // starten nur, falls es nicht abgewaehlt wurde if (!commandline.hasOption("nostart")) { System.err.println("info: starting processmanager for instance " + p2.getOutfilebinary()); String aufrufString = ini.get("apps", "pkraft-manager") + " -instance " + p2.getOutfilebinary(); System.err.println("calling: " + aufrufString); ArrayList<String> processSyscallWithArgs = new ArrayList<String>( Arrays.asList(aufrufString.split(" "))); ProcessBuilder pb = new ProcessBuilder(processSyscallWithArgs); // ProcessBuilder pb = new ProcessBuilder("processmanager -instance "+p2.getOutfilebinary()); // Map<String,String> env = pb.environment(); // String path = env.get("PATH"); // System.out.println("PATH: "+path); // java.lang.Process p = pb.start(); System.err.println("pid: " + p.hashCode()); } else { System.err.println("info: NOT starting processmanager for instance " + p2.getOutfilebinary()); } }
From source file:IndexService.IndexServer.java
public static void main(String[] args) { File stop = new File("/tmp/.indexstop"); File running = new File("/tmp/.indexrunning"); if (args != null && args.length > 0 && args[0].equals("stop")) { try {/* ww w. java2s. c o m*/ stop.createNewFile(); running.delete(); } catch (IOException e) { e.printStackTrace(); } return; } if (running.exists() && (System.currentTimeMillis() - running.lastModified() < 15000)) { long time = running.lastModified(); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } if (running.lastModified() == time) { running.delete(); } else { return; } } if (stop.exists()) { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } if (stop.exists()) stop.delete(); } Configuration conf = new Configuration(); IndexServer server = new IndexServer(conf); if (args != null && args.length > 0 && args[0].equals("test")) { server.testmode = true; } server.start(); try { running.createNewFile(); } catch (IOException e) { e.printStackTrace(); } new UserCmdProc(server).start(); while (true) { stop = new File("/tmp/.indexstop"); if (stop.exists()) { server.close(); running.delete(); stop.delete(); break; } try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } running.setLastModified(System.currentTimeMillis()); } }
From source file:gda.plots.SimplePlot.java
/** * Temporary main for speed testing purposes only * //w ww . j a va 2s.c o m * @param args */ public static void main(String args[]) { JFrame jf = new JFrame(); final SimplePlot sp = new SimplePlot(); jf.getContentPane().add(sp); jf.pack(); jf.setVisible(true); sp.setXAxisAutoScaling(false); sp.setXAxisLimits(0.0, 300.0); sp.setYAxisLimits(0.0, 1.0); sp.initializeLine(0); final double x[] = new double[1000]; final double y[] = new double[1000]; final double[] numbers = new double[10]; final double[] timesOne = new double[10]; final double[] timesTwo = new double[10]; for (int i = 0; i < 1000; i++) x[i] = i; try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { long timeOne; long timeTwo; for (int j = 0; j < 10; j++) { sp.initializeLine(j); timeOne = System.currentTimeMillis(); for (int k = 0; k < 300; k++) { y[k] = Math.random(); sp.addPointToLine(j, x[k], y[k]); } timeTwo = System.currentTimeMillis(); numbers[j] = j; timesOne[j] = timeTwo - timeOne; System.out.println("LINE " + j + " " + timesOne[j]); } } }); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { sp.deleteAllLines(); } }); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { long timeOne; long timeTwo; // SimpleXYSeries[] lines = new SimpleXYSeries[10]; // sp.setBatchingRepaints(true); for (int j = 0; j < 10; j++) { sp.initializeLine(j); // lines[j] = sp.getActualLine(j); timeOne = System.currentTimeMillis(); for (int k = 0; k < 300; k++) { y[k] = Math.random(); } // lines[j].setPoints(x, y); sp.setLinePoints(j, x, y); timeTwo = System.currentTimeMillis(); timesTwo[j] = timeTwo - timeOne; System.out.println("LINE " + j + " " + (timeTwo - timeOne)); } } }); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { sp.deleteAllLines(); } }); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { sp.initializeLine(0); sp.setLinePoints(0, numbers, timesOne); sp.initializeLine(1); sp.setLinePoints(1, numbers, timesTwo); } }); } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }
From source file:Wait.java
public static void bySeconds(long s) { try {// w ww. j a va 2 s . co m Thread.currentThread().sleep(s * 1000); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Wait.java
public static void oneSec() { try {//from w w w .ja v a 2 s. co m Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Wait.java
public static void manySec(long s) { try {/*w w w .j a v a 2 s .c o m*/ Thread.currentThread().sleep(s * 1000); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
public static void print() { int counter = 1; while (true) { try {//from ww w. ja v a 2s . c om System.out.println("Counter:" + counter++); Thread.sleep(2000); // sleep for 2 seconds } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:Main.java
public static void print() { for (int i = 1; i <= 5; i++) { try {/*from w ww. j ava 2 s. c o m*/ System.out.println("Counter: " + i); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }