
Alexander
21.04.2018
14:11:21
Ээ
public static void main(String... args) {
ForkJoinPool pool = ForkJoinPool.commonPool();
pool.execute(() -> {
System.out.println(pool);
System.out.println(ForkJoinTask.getPool());
});
}
java.util.concurrent.ForkJoinPool@76527921[Running, parallelism = 7, size = 1, active = 1, running = 1, steals = 0, tasks = 0, submissions = 0]
java.util.concurrent.ForkJoinPool@76527921[Running, parallelism = 7, size = 1, active = 1, running = 1, steals = 0, tasks = 0, submissions = 0]
public static void main(String... args) {
ForkJoinPool pool = ForkJoinPool.commonPool();
System.out.println(pool);
Stream.generate(() -> RandomUtils.nextInt(0, 100))
.limit(10)
.parallel()
.forEach(number -> {
System.out.println(ForkJoinTask.getPool());
});
}
тоже самое
ну и классика
public static void main(String... args) throws InterruptedException {
ForkJoinPool pool = ForkJoinPool.commonPool();
System.out.println(pool);
ForkJoinPool newPool = new ForkJoinPool();
System.out.println(newPool);
newPool.execute(() -> {
Stream.generate(() -> RandomUtils.nextInt(0, 100))
.limit(10)
.parallel()
.forEach(number -> {
System.out.println(ForkJoinTask.getPool());
});
});
Thread.sleep(1000);
}
java.util.concurrent.ForkJoinPool@654f0d9c[Running, parallelism = 7, size = 0, active = 0, running = 0, steals = 0, tasks = 0, submissions = 0]
java.util.concurrent.ForkJoinPool@6a400542[Running, parallelism = 8, size = 0, active = 0, running = 0, steals = 0, tasks = 0, submissions = 0]
java.util.concurrent.ForkJoinPool@6a400542[Running, parallelism = 8, size = 8, active = 8, running = 5, steals = 9, tasks = 0, submissions = 0]
java.util.concurrent.ForkJoinPool@6a400542[Running, parallelism = 8, size = 8, active = 1, running = 1, steals = 16, tasks = 0, submissions = 0]

Daniel
21.04.2018
19:48:24
If you have a relational databases background, the fact that Redis commands can fail during a transaction, but still Redis will execute the rest of the transaction instead of rolling back, may look odd to you.
However there are good opinions for this behavior:
* Redis commands can fail only if called with a wrong syntax (and the problem is not detectable during the command queueing), or against keys holding the wrong data type: this means that in practical terms a failing command is the result of a programming errors, and a kind of error that is very likely to be detected during development, and not in production.
* Redis is internally simplified and faster because it does not need the ability to roll back.
лол