From 77599328df02af84a937ec844cc8215f3f3660a8 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Mon, 24 Jul 2017 13:38:37 +0200
Subject: [PATCH] added thread pointcut examples
---
src/aspects/ThreadAspect.aj | 24 +++++++++++++++++++++++
src/examples/ThreadOperationsExample.java | 16 +++++++++++++++
2 files changed, 40 insertions(+)
create mode 100644 src/aspects/ThreadAspect.aj
create mode 100644 src/examples/ThreadOperationsExample.java
diff --git a/src/aspects/ThreadAspect.aj b/src/aspects/ThreadAspect.aj
new file mode 100644
index 0000000..0983d49
--- /dev/null
+++ b/src/aspects/ThreadAspect.aj
@@ -0,0 +1,24 @@
+package aspects;
+
+public aspect ThreadAspect {
+
+ before() : execution(* java.lang.Thread.start(..)) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+
+ before() : call(* java.lang.Thread.start(..)) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+
+ before() : call(* java.lang.Thread.run(..)) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+
+ before() : execution(java.lang.Thread.new(..)) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+
+ before() : call(java.lang.Thread.new(..)) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+}
diff --git a/src/examples/ThreadOperationsExample.java b/src/examples/ThreadOperationsExample.java
new file mode 100644
index 0000000..bf98df2
--- /dev/null
+++ b/src/examples/ThreadOperationsExample.java
@@ -0,0 +1,16 @@
+package examples;
+
+public class ThreadOperationsExample {
+
+ public static void main(String[] args) throws InterruptedException {
+ Thread thread = createThread();
+ thread.start();
+
+ thread.join();
+ }
+
+ private static Thread createThread() {
+ return new Thread();
+ }
+
+}
--
GitLab