本文整理了Java中java.lang.Thread.run()
方法的一些代码示例,展示了Thread.run()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.run()
方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:run
[英]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.
Subclasses of Thread
should override this method.
[中]如果此线程是使用单独的Runnable
运行对象构造的,则调用Runnable
对象的run
方法;否则,此方法不执行任何操作并返回。Thread
的子类应重写此方法。
代码示例来源:origin: apache/hbase
@Override
public void run() {
super.run();
}
}
代码示例来源:origin: stackoverflow.com
"My thread" prio=10 tid=0x00007fffec015800 nid=0x1775 waiting for monitor entry [0x00007ffff15e5000]
java.lang.Thread.State: BLOCKED (on object monitor)
at LockTest.intrinsicLock(LockTest.java:9)
- waiting to lock <0x00000007d6a33b10> (a LockTest)
at LockTest$1.run(LockTest.java:11)
at java.lang.Thread.run(Thread.java:662)
代码示例来源:origin: stanfordnlp/CoreNLP
/** Kills this process, and kills the stream gobblers waiting on it. */
public void kill() {
Runtime.getRuntime().removeShutdownHook(shutdownHoook);
shutdownHoook.run();
}
代码示例来源:origin: square/picasso
@Override public void run() {
Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND);
super.run();
}
}
代码示例来源:origin: sarxos/webcam-capture
@Override
public void run() {
super.run();
if (file.exists()) {
if (!file.delete()) {
LOG.warn("JVM was not able to remove file {}", file);
}
}
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void run()
{
try
{
super.run();
}
finally
{
OtherThreadExecutor.this.thread = null;
}
}
};
代码示例来源:origin: neo4j/neo4j
@Override
public void run()
{
try
{
super.run();
}
finally
{
monitor.threadFinished( threadNamePrefix );
}
}
};
代码示例来源:origin: eclipse-vertx/vert.x
private void setupCacheDir() {
String cacheDirName = CACHE_DIR_BASE + "/file-cache-" + UUID.randomUUID().toString();
cacheDir = new File(cacheDirName);
if (!cacheDir.mkdirs()) {
throw new IllegalStateException("Failed to create cache dir");
}
// Add shutdown hook to delete on exit
synchronized (this) {
shutdownHook = new Thread(() -> {
CountDownLatch latch = new CountDownLatch(1);
new Thread(() -> {
try {
deleteCacheDir();
} catch (IOException ignore) {
}
latch.countDown();
}).run();
try {
latch.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
}
代码示例来源:origin: qiujuer/Genius-Android
@Override
public void run() {
super.run();
while (mRunAsyncThread && count < 10000) {
add();
sleepIgnoreInterrupt(0, 500);
}
}
代码示例来源:origin: qiujuer/Genius-Android
@Override
public void run() {
super.run();
while (mRunSyncThread && count < 10000) {
add();
sleepIgnoreInterrupt(0, 500);
}
}
代码示例来源:origin: checkstyle/checkstyle
public void foo19() {
(new Thread(new Runnable() {
@Override
public void run() {
}
})).
run();
// comment
}
代码示例来源:origin: checkstyle/checkstyle
public void foo20() {
(new Thread(new Runnable() {
@Override
public void run() {
}
})).
run();
// violation
}
代码示例来源:origin: bumptech/glide
@Override
public void run() {
super.run();
try {
test.runTest();
} catch (Exception e) {
exception = e;
}
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Execute the thread's {@code Runnable}. Logs a trace message at the start and end of execution.
*/
public void run() {
Messages.msg.tracef("Thread \"%s\" starting execution", this);
try {
super.run();
} finally {
Messages.msg.tracef("Thread \"%s\" exiting", this);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Override
public void run()
{
super.run();
trigger();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Override
public void run()
{
super.run();
trigger();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory run(Environment env, Memory... args){
invoker.setTrace(env.trace());
thread.run();
return Memory.NULL;
}
代码示例来源:origin: stackoverflow.com
"My thread" prio=10 tid=0x00007fffec082800 nid=0x17e8 waiting on condition [0x00007ffff14eb000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007d6a33d30> (a java.util.concurrent.locks.ReentrantLock$FairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178)
at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:201)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
at LockTest.reentrantLock(LockTest.java:22)
at LockTest$2.run(LockTest.java:25)
at java.lang.Thread.run(Thread.java:662)
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void test() {
new Thread(() -> {
testComplete();
try {
fail();
} catch (Throwable ignore) {
}
latch.countDown();
}).run();
}
}
代码示例来源:origin: bumptech/glide
@Override
public void run() {
// why PMD suppression is needed: https://github.com/pmd/pmd/issues/808
android.os.Process.setThreadPriority(DEFAULT_PRIORITY); //NOPMD AccessorMethodGeneration
if (preventNetworkOperations) {
StrictMode.setThreadPolicy(
new ThreadPolicy.Builder()
.detectNetwork()
.penaltyDeath()
.build());
}
try {
super.run();
} catch (Throwable t) {
uncaughtThrowableStrategy.handle(t);
}
}
};
内容来源于网络,如有侵权,请联系作者删除!