Revert "BAEL-4134"
This commit is contained in:
committed by
GitHub
parent
dffa1f64e6
commit
485b4e3e99
@@ -13,4 +13,6 @@ This module contains articles about advanced topics about multithreading with co
|
||||
- [Java Thread Deadlock and Livelock](https://www.baeldung.com/java-deadlock-livelock)
|
||||
- [Guide to AtomicStampedReference in Java](https://www.baeldung.com/java-atomicstampedreference)
|
||||
- [The ABA Problem in Concurrency](https://www.baeldung.com/cs/aba-concurrency)
|
||||
- [Introduction to Lock-Free Data Structures](https://www.baeldung.com/lock-free-programming)
|
||||
- [Introduction to Exchanger in Java](https://www.baeldung.com/java-exchanger)
|
||||
- [[<-- previous]](/core-java-modules/core-java-concurrency-advanced-2)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.thisescape;
|
||||
|
||||
public class ImplicitEscape {
|
||||
|
||||
public ImplicitEscape() {
|
||||
Thread t = new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Started...");
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.thisescape;
|
||||
|
||||
public class LoggerRunnable implements Runnable {
|
||||
|
||||
public LoggerRunnable() {
|
||||
Thread thread = new Thread(this); // this escapes
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Started...");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.thisescape;
|
||||
|
||||
public class SafePublication implements Runnable {
|
||||
|
||||
private final Thread thread;
|
||||
|
||||
public SafePublication() {
|
||||
thread = new Thread(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Started...");
|
||||
}
|
||||
|
||||
public void start() {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SafePublication publication = new SafePublication();
|
||||
publication.start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user