interview questions
redis duringmq消息队列结构,怎么放消息,怎么使用
synchronize lock幂等性hashtable and hashmapred-black tree锁使用情况,乐观悲观可重入reference article
the status of lock针对synchronized(悲观锁)关键字(JVM),锁有四种状态:无锁,偏向锁,轻量级锁,重量级锁为什么synchronized实现线程同步?Hotspot的对象头主要包括两部分数据:Mark Word(标记字段)、Klass Pointer(类型指针)现在话题回到synchronized,synchronized通过Monitor来实现线程同步,Monitor是依赖于底层的操作系统的Mutex Lock(互斥锁)来实现的线程同步。如同我们在自旋锁中提到的“阻塞或唤醒一个Java线程需要操作系统切换CPU状态来完成,这种状态转换需要耗费处理器时间。如果同步代码块中的内容过于简单,状态转换消耗的时间有可能比用户代码执行的时间还要长”。这种方式就是synchronized最初实现同步的方式,这就是JDK 6之前synch ...
20-ValidParentheses
Here is the Original Post
Principle
stack: first in & last out 如果左括号入栈,遇到右括号时将对应栈顶左括号出栈,则遍历完所有括号后stack仍然为空。
establish hashtable dic construct corresponding relation, key-left brackets, value-right brackets, so it’s just O(1) time complexity to check if two brackests are in one-to-one correspondence. Here we build a stack to iterate stirng s, and judge it by algorithm.
Method12345678910111213st=>start: ccond1=>condition: s.length() > 0cond=>condition: Is c left bracket?op=>o ...
Percolation
Deques and Randomized Queues
Deploy kubernetes in Ubuntu 20.04
Kubernetes dashboardAs we see above the kubernetes-dashboard service in the kube-system namespace has a ClusterIP of 10.152.183.64 and listens on TCP port 443. The ClusterIP is randomly assigned, so if you follow these steps on your host, make sure you check the IP adress you got. Point your browser to https://10.1.29.1:30000 and you will see the kubernetes dashboard UI. To access the dashboard use the default token retrieved with:
12token=$(microk8s kubectl -n kube-system get secret | grep defa ...
A simple example of Spring Batch
Flow chart of Batch processing
Spring Batch constructed of 7 parts:
JobRepository: used for register Job container, set up database properties.
JobLauncher: used for start Job interface.
Job: the task that need to be excuted.
Step: just what it means.
ItemReader: read data from file and then map the field.
ItemProcessor: used for process data, meanwhile check it.
ItemWriter: used for output data, set up datasource, write pre-processing SQL command.
The project structure is this:
1 Generate mave ...
Parse helm chart to deployable yaml by Golang
In this project, I use gin web framework, which is written in Golang. It features a martini-like API with performance that is up to 40 times faster thanks to httprouter. Please visit the https://github.com/gin-gonic/gin#using-get-post-put-patch-delete-and-options website for more details.
Now, talk is cheap, here are the codes:
As normal, we need a main function:
123456package mainfunc main() { r := setupRouter() r.Run(":8080")}
Then, the route rule, we setup 2 routes ...
Java并发编程笔记(二)
14 Lock和Condition:monitor in Java.util.concurrent并发两大问题:互斥&同步Java SDK并发包通过Lock和Condition两个接口来实现管城,其中Lock用于解决互斥问题,Condition用于解决同步问题.与synchronized无法解决死锁造成的”破坏不可抢占条件”相比,Lock的三个接口专门解决该问题:
能够响应中断synchronized的问题是,持有锁A后,如果尝试获取锁B失败,则线程进入阻塞状态,一旦死锁,就没有任何机会来唤醒阻塞的线程.但如果阻塞的线程能够响应中断信号从而被唤醒,那它就有机会释放锁A.e.g.
123// 支持中断的APIvoid lockInterruptibly() throws InterruptedException;
支持超时如果线程超时后没有获取锁不是进入阻塞状态,而是返回一个error,那这个线程也有机会释放锁,也能破坏不可抢占条件.e.g.
12boolean tryLock(long time,TimeUnit unit) throws Interrupted ...
凭据
更改git账号
Demand delete interface
两种删除方式1. 第一种只逻辑删除demand表* DemandController123456789101112131415161718192021import com.yunlu.core.api.annotation.ApiDeclare;import org.slf4j.Logger;import org.slf4j.LoggerFactory;private static final Logger LOGGER = LoggerFactory.getLogger(DemandController.class); @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json;charset=utf-8") @ResponseBody @ApiDeclare(alias = "ncov.demand.delete") public ApiResult<Boolean> delete(@R ...
Deutsch
01 Folgen den PfeilenMarie, ich mache mir Sorgen.Was ist los?Ich wollte meine Mutter von der Arbeit abholen.Aber sie ist nicht hier.Das Gebaude ist leer.Hast du sie angerufen?Ja,aber sie antwortet nicht.Oh nein!Das Licht ist aus!oh je!Das ist schlimm!Ich weib!Es ist dunkel hier.Ich kann nicht raus!Die Tur ist abgeschlossen!On nein!Was machst du jetzt?Ich weib nicht..ich sehe etwas.Dort sind Pfeile auf dem Boden.Pfeile?Sie furhren die Treppen runter.Ich werde ihnen folgen.Nein,es ist gefahrlich!I ...