Example usage for java.lang Thread currentThread

List of usage examples for java.lang Thread currentThread

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native Thread currentThread();

Source Link

Document

Returns a reference to the currently executing thread object.

Usage

From source file:me.j360.dubbo.modules.util.concurrent.ThreadUtil.java

/**
 * StackTrace??./*  ww  w.  j  av a 2  s. c  om*/
 */
public static String getCallerClass() {
    StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
    if (stacktrace.length >= 4) {
        StackTraceElement element = stacktrace[3];
        return element.getClassName();
    } else {
        return StringUtils.EMPTY;
    }
}

From source file:com.ling.spring.task.FixedDelayTask.java

@Scheduled(fixedDelay = 5000)
public void runTask() {

    System.out.println("fixedDelay run..." + format.format(new Date()));
    try {// w  w  w .j  av a  2 s  .com
        Thread.currentThread().sleep(5000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.samczsun.helios.Resources.java

public static void loadAllImages() {
    if (Thread.currentThread() != Display.getDefault().getThread()) {
        throw new IllegalArgumentException("Wrong thread");
    }//from  ww w. j a v a 2  s  . c  o m
    for (Resources resources : Resources.values()) {
        try {
            resources.data = IOUtils.toByteArray(Resources.class.getResourceAsStream(resources.filePath));
            resources.image = new Image(Display.getDefault(), resources.getData());
        } catch (IOException exception) {
            ExceptionHandler.handle(exception);
        }
    }
}

From source file:Main.java

public void run() {
    int count = 0;
    while (animate) {
        try {//from w w w. j av  a 2s  . c o  m
            Thread.currentThread().sleep(200);
        } catch (Exception ex) {
        }
        frame.setCursor(cursors[count % cursors.length]);
        count++;
    }
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:Main.java

@Override
 public void start(Stage stage) {
     String name = Thread.currentThread().getName();
     System.out.println("start() method: " + name);

     // Add an Exit button to the scene
     Button exitBtn = new Button("Exit");
     exitBtn.setOnAction(e -> Platform.exit());

     Scene scene = new Scene(new Group(exitBtn), 300, 100);
     stage.setScene(scene);//from w  w  w  .j ava  2  s .c  o m
     stage.setTitle("JavaFX Application Life Cycle");
     stage.show();
 }

From source file:net.servicefixture.parser.TreeParserFactory.java

/**
 * Creates an <code>TreeParser</code> instance. Looks up system property
 * TreeParserFactory.TREE_PARSER_SYSPROP for the class name first. If not 
 * found, an <code>ExpressionTreeParser</code> instance will be created.
 *  //from   w  w w .j av a2  s.c  om
 */
public static TreeParser createTreeParser(String parserClazzName) {
    if (StringUtils.isEmpty(parserClazzName)) {
        parserClazzName = System.getProperty(TREE_PARSER_SYSPROP);
    }

    try {
        if (!StringUtils.isEmpty(parserClazzName)) {
            Class parserClazz = Thread.currentThread().getContextClassLoader().loadClass(parserClazzName);
            return (TreeParser) parserClazz.newInstance();
        }

        return new ExpressionTreeParser();
    } catch (Exception e) {
        throw new ServiceFixtureException("Unable to create TreeParser using class:" + parserClazzName + ".",
                e);
    }
}

From source file:Main.java

/**
 * Method to get absolute path based on relative path from src folder.
 * /*  ww w  .j  av  a 2  s . c  o  m*/
 * @param resource - relative path
 * @return absolute path
 */
public static String getPath(String resource) {
    String path = Thread.currentThread().getContextClassLoader().getResource(resource).getPath(); //relative path based on src folder, example resource= gpt/search/browse/browse-catalog.xml 
    return checkPath(path);
}

From source file:main.java.com.aosa.util.AOSAReadProperties.java

/**
 * Description<code>?Properties</code>      <br>
 * By mutou at 2012-1-12 ?05:48:25   <br>
 * String      <br>//from  w ww .  jav a  2s  . co  m
 * @param profileName
 *       Properties ??ClassPath
 * @param key
 *       ?? 
 * @return
 * @throws
 */
public static String ReadValue(String profileName, String key) {
    String value = null;
    Properties properties = new Properties();
    FileInputStream input = null;
    try {
        input = new FileInputStream(
                Thread.currentThread().getContextClassLoader().getResource("").getPath() + profileName);
        properties.load(input);
        value = properties.getProperty(key);
    } catch (FileNotFoundException e) {
        logger.debug("Properties");
        throw new AOSARuntimeException("Properties", e);
    } catch (IOException e) {
        logger.debug("PropertiesIO");
        throw new AOSARuntimeException("PropertiesIO", e);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                logger.debug("IO?");
                throw new AOSARuntimeException("IO?", e);
            }
        }
    }
    return value;
}

From source file:com.sap.prd.mobile.ios.mios.AlternatePublicHeaderFolderPathTest.java

@BeforeClass
public static void __setup() throws Exception {

    dynamicVersion = "1.0." + String.valueOf(System.currentTimeMillis());
    testName = AlternatePublicHeaderFolderPathTest.class.getName() + File.separator
            + Thread.currentThread().getStackTrace()[1].getMethodName();

    remoteRepositoryDirectory = getRemoteRepositoryDirectory(
            AlternatePublicHeaderFolderPathTest.class.getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion);

    Map<String, String> additionalSystemProperties = new HashMap<String, String>();
    additionalSystemProperties.put("mios.ota-service.url",
            "http://apple-ota.wdf.sap.corp:8080/ota-service/HTML");
    additionalSystemProperties.put("xcode.app.defaultConfigurations", "Release");
    additionalSystemProperties.put("xcode.app.defaultSdks", "iphoneos");
    additionalSystemProperties.put("archive.dir", "archive");
    additionalSystemProperties.put("xcode.useSymbolicLinks", Boolean.TRUE.toString());

    test(testName, new File(getTestRootDirectory(), "straight-forward/MyLibrary"), "deploy", THE_EMPTY_LIST,
            THE_EMPTY_MAP, pomReplacements, new AbstractProjectModifier() {

                @Override//from   ww  w  .j a va  2s  .  c om
                public void execute() throws Exception {
                    final File pom = new File(testExecutionDirectory, "pom.xml");

                    final Model model = getModel(pom);
                    Plugin plugin = model.getBuild().getPlugins().get(0);
                    Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
                    Xpp3Dom alternatePublicHeaderFolderPath = new Xpp3Dom("alternatePublicHeaderFolderPath");
                    alternatePublicHeaderFolderPath.setValue("MyLibrary");
                    configuration.addChild(alternatePublicHeaderFolderPath);

                    persistModel(pom, model);
                }
            });
}

From source file:de.document.service.UmlsService.java

public List<Umls> readAll() {
    List<Umls> umlsList = new ArrayList<>();

    try (Scanner s = new Scanner(
            (Thread.currentThread().getContextClassLoader().getResourceAsStream("Umls" + umlsterm)))) {
        while (s.hasNextLine()) {
            umlsList.add(new Umls(s.nextLine()));
        }//from  ww  w  .j  ava  2 s .c om
    }

    /* 
      Umls ob= new Umls();
      Umls ob1= new Umls(); 
      ob.setName("name");
      ob1.setName("name1");
      System.out.print(ob);
      }*/
    return umlsList;
}