Thursday, 24 September 2020

Thread Priority and Difference between Yield & Join


Understanding thread priorities

Understanding the Thread priorities is next important step in learning Multi-threading and specially how yield() works.

1. Remember that all the threads carry normal priority when a priority is not specified.
2. Priorities can be specified from 1 to 10. 10 being the highest, 1 being the lowest priority and 5 being 
        the normal priority.
3. Remember that the thread with highest priority will be given preference in execution. But there is no 
        guarantee that it will be in running state the moment it starts.
4. Always the currently executing thread might have the higher priority when compared to the threads 
        in the pool who are waiting for their chance.
5. It is the thread scheduler which decides what thread should be executed.
6. t.setPriority() can be used to set the priorities for the threads.
7. Remember that the priorities should be set before the threads start method is invoked.
8. You can use the constants, MIN_PRIORITY,MAX_PRIORITY and NORM_PRIORITY for setting 
         priorities.

Difference between Yield() and Join() method

Yield


Purpose: Yield means currently executing thread gives chance to the threads that have equal priority in the Thread-pool. Yield does not guarantee that it will change the state of the currently executing thread to runnable state immediately.

State Change: It can only make a thread from Running State to Runnable State, not in wait or blocked state.

Join


Purpose: The join() method of a Thread instance can be used to “join” the start of a thread’s execution to the end of another thread’s execution so that a thread will not start running until another thread has ended. If join() is called on a Thread instance, the currently running thread will block until the Thread instance has finished executing.

State Change: If the method join() called on the Thread instance, a thread will not start running until another thread finish executing. 























Monday, 14 September 2020

CircleCI Introduction

 

CircleCI


Question: What is Continuous Integration?


Continuous integration is a practice that encourages developers to integrate their code into the master branch of a shared repository. Instead of building out features in isolation and integrating them at the end of a development cycle, code is integrated with the shared repository by each developer multiple times throughout the day.


Every developer commits daily to a shared mainline.

Every commit triggers an automated build and test.

If build and test fails, then it will be easy to fix them rapidly.

Why we need Continuous integration ?


Improve team productivity/efficiency.

Identify problems and solve them, easily & quickly


Releasing a higher quality & more stable products.


CircleCI automates your software builds, tests, and deployments. We want to make 

engineering teams more productive through intelligent automation. CircleCI provides

enterprise-class support and services. CircleCI runs nearly one million jobs per day in support 

of 30,000 organisations.


Benefits of CircleCI


Organisations choose CircleCI because jobs run fast and builds can be optimised for 
speed.

CircleCI can be configured to run very complex pipelines efficiently with sophisticated 
caching, docker layer caching etc. 

As a developer using circleci.com, you can SSH into any job to debug your build issues.

We could set up parallel jobs in your .circleci/config.yml file to run jobs faster

We could also configure caching with two simple keys to reuse data from previous jobs in your 
workflow.

CircleCI provides monitoring and insights into your builds.


We could also get build and deployment logs to check the failures/errors.


After a software repository on GitHub or Bitbucket is authorised and added as a project 

to circleci.com, every code change triggers automated tests in a clean container or VM.


CircleCI runs each job in a separate container or VM, that Means each time your job runs


CircleCI spins up a container or VM to run the job in.


CircleCI then sends an email notification of success or failure after the tests complete. We

also have provision to include integrated Slack notifications. So that we will receive a 

notification for build and deployment every time.


CircleCI may be configured to deploy code to various environments, for example: AWS 

EC2 Container


Prerequisites for Running our first build


Basic knowledge of Git.

A GitHub/Bitbucket account, of which you are logged into.

An account on CircleCI.

Basic terminal or bash knowledge using the command line is helpful.


Setting up CircleCI


https://circleci.com/docs/2.0/local-cli/

https://circleci.com/docs/2.0/getting-started/


Question: what a Pipeline is?


Pipelines represent the entire configuration that is run when you trigger work on your projects 

that use CircleCI. The entirety of  a .circleci/config.yml file is executed by a pipeline.