ALL


  GoLang Interview Questions

Below lists some frequently asked GoLang interview questions and their corresponding answers based on the author's experience. The list is updated frequently with new understandings. Stay tuned.What is the GMP model of GoLang?GoLang uses goroutine to achieve concurrency and it is famous for high concurrency support as the language defines its own goroutine dispatching and processing system which is well known as GMP model.How it works is that M is normally defined as the OS thread being spawned( then each M thread should be associated with a Process queue and each Process queue can have multip...

591 0       MEMORY CONCURRENCY INTERVIEW QUESTION GOLANG


  errGroup in GoLang explained

Today, let's talk about the usage and applicable scenarios of errGroup, which is often used. Why is it useful? Generally, when we use goroutine, we cannot return a value. If you want to pass out the result of the goroutine execution, you usually have to use the channel. The errGroup package is suitable if you want to know when the goroutine you opened encounters an error during execution and stop working, and I need to know the error value.errGroup usageThe package needs to be downloaded and installed first. go get -u golang.org/x/syncAn example of using it would bepackage mainimport ( ...

6,919 0       CONCURRENCY GOLANG ERRGROUP WAITHROUP


  Deep Understanding of ReentrantLock: Unlocking the Mysteries of Java Concurrent Programming

ReentrantLock introductionReentrantLock is a class in the Java concurrent package, java.util.concurrent.locks, and is an implementation of the Lock interface. As its name suggests, it is a reentrant mutual exclusion lock.A mutual exclusion lock is a synchronization tool used to protect shared resources, ensuring that only one thread can access the resource at a given time. Reentrant means that a thread can acquire the same lock multiple times without causing a deadlock.This lock provides some basic behaviors that are the same as those of the built-in synchronization mechanism. For example, a t...

4,095 0       JAVA MULTITHREADING CONCURRENCY REENTRANTLOCK


  Mastering Go Channels: How to Build Concurrent Applications Like a Pro

IntroductionIn the world of concurrent programming, Go channels have quickly become a popular tool for building fast and efficient applications. Utilizing channels can help you take full advantage of the power of Go's lightweight threads, or goroutines, and enable you to easily and effectively manage data sharing and synchronization. In this article, we'll dive deep into the world of Go channels and show you how to build concurrent applications like a pro.Understanding Go ChannelsTo start, let's take a closer look at what Go channels are and how they work. In Go, channels are a way to communic...

829 0       CONCURRENCY GOLANG CHANNEL


  Practice of using spinlock instead of mutex

Spinlock and mutex are two important concepts in multithreading programs. They are used to lock some shared resource to prevent concurrent access which may affect data consistency. But they do have differences, what are the differences? when should we use spinlock instead of mutex?The TheoryIn theory, when a thread tries to lock a mutex and it does not succeed, because the mutex is already locked, it will go to sleep, immediately allowing another thread to run. It will continue to sleep until being woken up, which will be the case once the mutex is being unlocked by whatever thread was holding...

13,596 0       CONCURRENCY SPINLOCK MUTEX


  Concurrency vs Parallelism

Concurrency and parallelism are two related concepts which deal with executing tasks "simultaneously". From Sun's Multithreaded Programming Guide:Concurrency: A condition that exists when at least two threads are making progress. A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism.Parallelism: A condition that arises when at least two threads are executing simultaneously.These two definitions are too formal to be understood easily. On the Internet, there is one image which demonstrates the difference between these two in an easy way:Much e...

29,591 0       CONCURRENCY THREAD PARALLELISM


  Erlang Style Concurrency

Introduction On an evolutionary scale of innovation from one to ten (one being Bloomberg and Citi Group, eight being Google and Cirque Du Soleil, and ten being the company you couldn't imagine in your wildest dreams), the company I work for is about a three1. Being employed by this bastion of ingenuity affords me certain opportunities I can't get elsewhere. For example, every developer gets to interview potential candidates he might end up working with. During our last round of these int...

2,744 0       INNOVATION CONCURRENCY ERLANG LOCK MESSAGE


  Scala feels like EJB 2, and other thoughts

At Devoxx last week I used the phrase "Scala feels like EJB 2 to me". What was on my mind?ScalaFor a number of years on this blog I've been mentioning a desire to write a post about Scala. Writing such a post is not easy, because anyone who has been paying attention to anti-Scala blog posts will know that writing one is a sure fire way of getting flamed. The Scala community is not tolerant of dissent.But ultimately, I felt that it was important for me to speak out and express my opinions. As I said in my talk, if it was just me that had a poor opinion of Scala I would probably keep quiet (or t...

2,053 0       SCALA FEATURE MODULE EJB CONCURRENCY