thread-synchronization

Code utility to synchronize two or more concurrent thread processes so they don't execute simultaneously critical code sections

License

License

GroupId

GroupId

com.hubbledouble
ArtifactId

ArtifactId

thread-synchronization
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

thread-synchronization
Code utility to synchronize two or more concurrent thread processes so they don't execute simultaneously critical code sections
Project URL

Project URL

https://github.com/hubbledouble/thread-synchronization
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

http://github.com/hubbledouble/thread-synchronization

Download thread-synchronization

How to add to project

<!-- https://jarcasting.com/artifacts/com.hubbledouble/thread-synchronization/ -->
<dependency>
    <groupId>com.hubbledouble</groupId>
    <artifactId>thread-synchronization</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.hubbledouble/thread-synchronization/
implementation 'com.hubbledouble:thread-synchronization:1.0.0'
// https://jarcasting.com/artifacts/com.hubbledouble/thread-synchronization/
implementation ("com.hubbledouble:thread-synchronization:1.0.0")
'com.hubbledouble:thread-synchronization:jar:1.0.0'
<dependency org="com.hubbledouble" name="thread-synchronization" rev="1.0.0">
  <artifact name="thread-synchronization" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.hubbledouble', module='thread-synchronization', version='1.0.0')
)
libraryDependencies += "com.hubbledouble" % "thread-synchronization" % "1.0.0"
[com.hubbledouble/thread-synchronization "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-data-mongodb jar 2.3.0.RELEASE
junit : junit jar 4.13

Project Modules

There are no modules declared in this project.

Thread Synchronization

Ensures two or more concurrent thread processes be synchronized so they don't execute simultaneously critical code sections. Using this library makes it easy to focus on the business process than worrying about performing thread synchronization while executing the same process code in two or more distributed nodes.

For more about thread synchronization, please visit here

Usage example:
Import the following library

<dependency>
	<groupId>com.hubbledouble</groupId>
	<artifactId>thread-synchronization</artifactId>
	<version>1.0.0</version>
</dependency>

 
External requirements:

  • Mongo database (this libreary will write to it for synchronizing the processes)
  • Spring Mongo Data dependency
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

 
Sample java code:

import com.hubbledouble.thread.synchronization.ThreadSynchronization;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;

public class Application {

    private static final ThreadSynchronization THREAD_SYNCHRONIZATION = threadSynchronization(mongoTemplate());

    public static MongoTemplate mongoTemplate() {

        MongoClient mongo = MongoClients.create();
        return new MongoTemplate(mongo, "databaseName");

    }

    public static ThreadSynchronization threadSynchronization(MongoOperations mongoOperations) {
        return new ThreadSynchronization(mongoOperations);
    }

    public static void main(String[] args) {

        THREAD_SYNCHRONIZATION.execute("processName", () ->
                System.out.println("Hello synchronized world!")
        );

    }

}

Versions

Version
1.0.0