Example usage for java.lang Thread run

List of usage examples for java.lang Thread run

Introduction

In this page you can find the example usage for java.lang Thread run.

Prototype

@Override
public void run() 

Source Link

Document

If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.

Usage

From source file:com.filemanager.free.activities.TextReader.java

public void onDestroyActionMode() {

    // clearing all the spans
    Thread clearSpans = new Thread(this);
    clearSpans.run();
}

From source file:net.itransformers.idiscover.discoverylisteners.PostDiscovererDeviceLogger.java

public void handleDevice(final String deviceName, RawDeviceData rawData,
        DiscoveredDeviceData discoveredDeviceData, Resource resource) {

    final Map<String, String> params = new HashMap<String, String>();
    params.put("deviceName", deviceName);
    params.put("deviceType", resource.getDeviceType());
    params.put("protocol", "ssh");
    params.put("address", resource.getIpAddress().getIpAddress());

    ResourceType resourceType = resourceManager.findResource(params);
    if (resourceType != null) {

        List connectParameters = resourceType.getConnectionParams();
        for (int i = 0; i < connectParameters.size(); i++) {
            ConnectionParamsType connParamsType = (ConnectionParamsType) connectParameters.get(i);

            String connectionType = connParamsType.getConnectionType();
            if (connectionType.equalsIgnoreCase(params.get("protocol"))) {

                for (ParamType param : connParamsType.getParam()) {
                    params.put(param.getName(), param.getValue());
                }//from  w ww  . j a v  a 2  s.com

            }
        }

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {

                    reportManager.reportExecutor(postDiscoveryPath, params);
                } catch (Exception e) {
                    logger.debug("Unable to execute a report for device " + deviceName, e); //To change body of catch statement use File | Settings | File Templates.

                }
            }
        });

        thread.run();
    }

}

From source file:com.filemanager.free.activities.TextReader.java

@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

    // clearing before adding new values
    if (searchEditText != null && charSequence.hashCode() == searchEditText.getText().hashCode()) {
        try {//from  ww w .j a  v  a  2 s . c  om
            if (searchTextTask != null)
                searchTextTask.cancel(true);

            nodes.clear();
            mCurrent = -1;
            mLine = 0;

            Thread clearSpans = new Thread(this);
            clearSpans.run();
        } catch (NullPointerException e) {
            e.printStackTrace();
        }

    }
}

From source file:org.ueu.uninet.it.IragarkiaBidali.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case PICK_IMAGE:
        if (resultCode == Activity.RESULT_OK) {
            Uri selectedImageUri = data.getData();

            try {
                // OI Fitxategi kudeatzailea
                String filemanagerstring = selectedImageUri.getPath();

                // MEDIA galeria
                String selectedImagePath = getPath(selectedImageUri);

                if (selectedImagePath != null) {
                    filePath = selectedImagePath;
                } else if (filemanagerstring != null) {
                    filePath = filemanagerstring;
                } else {
                    Toast.makeText(getApplicationContext(), "Kokapen ezezaguna", Toast.LENGTH_LONG).show();
                }/*  ww w .  ja va2  s. c om*/

                if (filePath != null) {
                    Thread haria = new Thread() {
                        @Override
                        public void run() {
                            decodeFile(filePath);
                        }
                    };
                    haria.run();

                } else {
                    bitmap = null;
                }
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "Barne-errore bat egon da.", Toast.LENGTH_LONG).show();
            }
        }
        break;
    default:
    }
}

From source file:net.rptools.maptool.client.MapTool.java

public static void startWebAppServer(final int port) {
    try {/*from w w w.  j  a  v a2s.  com*/
        Thread webAppThread = new Thread() {
            @Override
            public void run() {
                webAppServer.setPort(port);
                webAppServer.startServer();
            }
        };

        webAppThread.run();
    } catch (Exception e) { // TODO: This needs to be logged
        System.out.println("Unable to start web server");
        e.printStackTrace();
    }
}

From source file:org.pentaho.platform.osgi.KarafBoot.java

@Override
public boolean startup(IPentahoSession session) {
    try {//from  ww w  .  j a  v a2 s  .  c o m
        String solutionRootPath = PentahoSystem.getApplicationContext().getSolutionRootPath();
        String root = new File(solutionRootPath + "/system/karaf").getAbsolutePath();

        System.setProperty("karaf.home", root);
        System.setProperty("karaf.base", root);
        System.setProperty("karaf.data", root + "/data");
        System.setProperty("karaf.history", root + "/data/history.txt");
        System.setProperty("karaf.instances", root + "/instances");
        System.setProperty("karaf.startLocalConsole", "false");
        System.setProperty("karaf.startRemoteShell", "true");
        System.setProperty("karaf.lock", "false");
        System.setProperty("karaf.etc", root + "/etc");
        System.setProperty("felix.fileinstall.dir", root + "/etc"); // Default is '' which results in serious performance hit

        // Tell others like the pdi-osgi-bridge that there's already a karaf instance running so they don't start
        // their own.
        System.setProperty("embedded.karaf.mode", "true");

        // set the location of the log4j config file, since OSGI won't pick up the one in webapp
        System.setProperty("log4j.configuration", "file:" + solutionRootPath + "/system/osgi/log4j.xml");
        // Setting ignoreTCL to true such that the OSGI classloader used to initialize log4j will be the
        // same one used when instatiating appenders.
        System.setProperty("log4j.ignoreTCL", "true");

        expandSystemPackages(root + "/etc/custom.properties");

        // Wrap the startup of Karaf in a child thread which has explicitly set a bogus authentication. This is
        // work-around and issue with Karaf inheriting the Authenticaiton set on the main system thread due to the
        // InheritableThreadLocal backing the SecurityContext. By setting a fake authentication, calls to the
        // org.pentaho.platform.osgi.SpringSecurityLoginModule always challenge the user.
        Thread karafThread = new Thread(new Runnable() {

            @Override
            public void run() {
                // Bogus authentication
                SecurityContextHolder.getContext().setAuthentication(
                        new UsernamePasswordAuthenticationToken(UUID.randomUUID().toString(), ""));
                main = new Main(new String[0]);
                try {
                    main.launch();
                } catch (Exception e) {
                    main = null;
                    logger.error("Error starting Karaf", e);
                }
            }
        });
        karafThread.setDaemon(true);
        karafThread.run();
        karafThread.join();
    } catch (Exception e) {
        main = null;
        logger.error("Error starting Karaf", e);
    }
    return main != null;
}

From source file:net.yacy.kelondro.util.FileUtils.java

/**
 * Because the checking of very large files for their charset may take some time, we do this concurrently in this method
 * This method does not return anything but it logs an info line if the charset is a good choice
 * and it logs a warning line if the choice was bad.
 * @param file the file to be checked/*from www . ja  v  a  2 s.c  o  m*/
 * @param givenCharset the charset that we consider to be valid
 * @param concurrent if this shall run concurrently
 */
public static void checkCharset(final File file, final String givenCharset, final boolean concurrent) {
    Thread t = new Thread("FileUtils.checkCharset") {
        @Override
        public void run() {
            try {
                List<String> charsets = FileUtils.detectCharset(file);
                if (charsets.contains(givenCharset)) {
                    ConcurrentLog.info("checkCharset", "appropriate charset '" + givenCharset
                            + "' for import of " + file + ", is part one detected " + charsets);
                } else {
                    ConcurrentLog.warn("checkCharset", "possibly wrong charset '" + givenCharset
                            + "' for import of " + file + ", use one of " + charsets);
                }
            } catch (IOException e) {
            }

        }
    };
    if (concurrent)
        t.start();
    else
        t.run();
}

From source file:org.rifidi.designer.library.basemodels.gate.GateEntity.java

/**
 * Turns off the reader associated with the gate.
 *///from w w  w  .j  a v a 2 s  .c  o m
public void turnOff() {
    try {

        Thread thr = new Thread(new Runnable() {

            /*
             * (non-Javadoc)
             * 
             * @see java.lang.Runnable#run()
             */
            @Override
            public void run() {

                try {
                    readerModuleManagerInterface.turnReaderOff();
                    running = false;
                } catch (Exception e) {
                    logger.error("Problem turning on gate: " + e);
                }
            }

        });
        thr.run();
    } catch (Exception e) {
        e.printStackTrace();
    }
    for (VisualEntity entity : children) {
        ((AntennaFieldEntity) entity).turnOff();
    }
}

From source file:org.apache.hadoop.hbase.regionserver.TestScanner.java

private int count(final HRegionIncommon hri, final int flushIndex, boolean concurrent) throws IOException {
    LOG.info("Taking out counting scan");
    ScannerIncommon s = hri.getScanner(HConstants.CATALOG_FAMILY, EXPLICIT_COLS, HConstants.EMPTY_START_ROW,
            HConstants.LATEST_TIMESTAMP);
    List<Cell> values = new ArrayList<Cell>();
    int count = 0;
    boolean justFlushed = false;
    while (s.next(values)) {
        if (justFlushed) {
            LOG.info("after next() just after next flush");
            justFlushed = false;// www.j av  a2 s .c  om
        }
        count++;
        if (flushIndex == count) {
            LOG.info("Starting flush at flush index " + flushIndex);
            Thread t = new Thread() {
                public void run() {
                    try {
                        hri.flushcache();
                        LOG.info("Finishing flush");
                    } catch (IOException e) {
                        LOG.info("Failed flush cache");
                    }
                }
            };
            if (concurrent) {
                t.start(); // concurrently flush.
            } else {
                t.run(); // sync flush
            }
            LOG.info("Continuing on after kicking off background flush");
            justFlushed = true;
        }
    }
    s.close();
    LOG.info("Found " + count + " items");
    return count;
}