-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02132bd
commit 9d0ba52
Showing
4 changed files
with
12 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
testng-core/src/test/java/test/listeners/factory/ExampleListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
package test.listeners.factory; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import org.testng.IExecutionListener; | ||
|
||
public class ExampleListener implements IExecutionListener { | ||
|
||
public static ExampleListener instance; | ||
|
||
private static final AtomicBoolean once = new AtomicBoolean(false); | ||
private static final AtomicReference<ExampleListener> instance = new AtomicReference<>(); | ||
|
||
public ExampleListener() { | ||
setInstance(this); | ||
} | ||
|
||
private static void setInstance(ExampleListener instance) { | ||
if (once.compareAndSet(false, true)) { | ||
if (ExampleListener.instance == null) { | ||
ExampleListener.instance = instance; | ||
} | ||
} | ||
ExampleListener.instance.compareAndSet(null, instance); | ||
} | ||
|
||
public static ExampleListener getInstance() { | ||
return instance.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters