Kotlin: how to achieve multi-threaded synchronization?

Problem backgroundMultithreaded tasks to be executed: Task 1 and task 2 are executed in parallel; When all execution is completed, execute task 3.// Each task takes time to simulate through sleep val task1: () -> String = { sleep(2000) "Hello".also { println("task1 finished: $it") } } val task2: () -> String = { sleep(2000) ...

Posted on Tue, 07 Dec 2021 03:49:30 -0500 by lulon83

java version of gRPC practice 6: the client dynamically obtains the server address

Links to the full series of "java version gRPC actual combat"Generate code with protoService publishing and invocationServer streamClient streamBidirectional flowThe client dynamically obtains the server addressRegistration discovery based on eurekaWhy does the client get the server address dynamicallyThis article is the sixth in the ...

Posted on Tue, 07 Dec 2021 01:50:26 -0500 by Jaguar

The factory mode of design mode is the strongest in history. It's hard to argue against it!

Design pattern is a high-level abstract summary of various codes written in your actual work. If you don't learn design pattern, the abstraction ability will certainly not be too strong. There are 23 common design patterns. Today we only talk about the simplest factory pattern.Factory mode is a creation mode, which obtains new objects one by on ...

Posted on Tue, 07 Dec 2021 01:46:08 -0500 by sheffrem

SpringBoot integrates Spring Cache to simplify distributed cache development

prefaceLast blog post, we This paper deeply introduces the integration of spring boot and Redis We use RedisTemplate or StringRedisTemplate to select different data structures in combination with scenarios, which will cause the cache code and business code to be tightly coupled. Is there a simpler way?Answer: Yes, SpringCache.In this blog post, ...

Posted on Tue, 07 Dec 2021 03:34:41 -0500 by siri

Summary of common Spring Boot annotations

  Summary of common Spring Boot annotations 1, Start annotation @ SpringBootApplication @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = ...

Posted on Tue, 07 Dec 2021 01:46:28 -0500 by AMV

Some Tips in Kotlin development

Scope function selection At present, there are let, run, with and apply   and   also five scope functions. The official document has a table to illustrate the differences between them: To sum up, there are several differences: 1. apply and also return context objects. 2,let,run   And with return lambda results. 3. The ref ...

Posted on Tue, 07 Dec 2021 03:21:03 -0500 by febrarian