Skip to content

Commit 3db8507

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 34608da + a47864e commit 3db8507

18 files changed

+1263
-1
lines changed

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ repositories {
1919

2020
dependencies {
2121
implementation("org.springframework.boot:spring-boot-starter")
22+
implementation("org.springframework.boot:spring-boot-starter-web")
23+
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
24+
runtimeOnly("com.h2database:h2:2.2.224")
25+
26+
implementation("org.springframework.boot:spring-boot-starter-actuator")
27+
2228
testImplementation("org.springframework.boot:spring-boot-starter-test")
2329
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2430
}

img/amdahls_law.png

22.6 KB
Loading
Lines changed: 113 additions & 0 deletions
Loading
Lines changed: 94 additions & 0 deletions
Loading

img/comparing_queue.png

44.3 KB
Loading
59.7 KB
Loading

img/number_of_processors.png

116 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package example.concurrency;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example.concurrency.ch10;
2+
3+
import org.springframework.stereotype.Service;
4+
import org.springframework.transaction.annotation.Propagation;
5+
import org.springframework.transaction.annotation.Transactional;
6+
7+
@Service
8+
public class InnerService {
9+
10+
@Transactional(propagation = Propagation.REQUIRES_NEW)
11+
public void innerMethod() {
12+
System.out.printf("InnerService.innerMethod is called by %s%n", Thread.currentThread().getName());
13+
}
14+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package example.concurrency.ch10;
2+
3+
import java.sql.Connection;
4+
import javax.sql.DataSource;
5+
import org.springframework.jdbc.datasource.DataSourceUtils;
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.transaction.annotation.Transactional;
8+
9+
@Service
10+
public class OuterService {
11+
12+
private final InnerService innerService;
13+
14+
public OuterService(InnerService innerService) {
15+
this.innerService = innerService;
16+
}
17+
18+
@Transactional
19+
public void outerMethod() {
20+
System.out.printf("OuterService.outerMethod is called by %s%n", Thread.currentThread().getName());
21+
try {
22+
Thread.sleep(1000);
23+
innerService.innerMethod();
24+
} catch (Exception e) {
25+
throw new RuntimeException(e.getMessage());
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)