0%

在许多大型项目里都广泛用到了设计模式,使用设计模式可以使得代码更具有可扩展性。这里通过一个简单的例子来初探设计模式的思想。

阅读全文 »

问题描述

Santa Claus sleeps in his shop at the North Pole and can only be wakened by either

  1. all nine reindeer being back from their vacation in the South Pacific, or

  2. some of the elves having difficulties making toys;

To allow Santa to get some sleep, the elves can only wake him when three of them have problems. When three elves are having their problems solved, any other elves wishing to visit Santa must wait for those elves to return. If Santa wakes up to find three elves waiting at his shop’s door, along with the last reindeer having come back from the tropics, Santa has decided that the elves can wait until after Christmas, because it is more important to get his sleigh ready. (It is assumed that the reindeer do not want to leave the tropics, and therefore they stay there until the last possible moment.) The last reindeer to arrive must get Santa while the others wait in a warming hut before being harnessed to the sleigh.

Solve this problem using semaphores.

阅读全文 »

互斥与同步

当有多个进程或多个线程对共享资源进行访问时,由于进程或线程的执行顺序有随机性,资源访问的结果也会具有随机性,为了保证结果的正确,需要互斥和同步机制。

互斥:一个资源一次只能被一个进程或线程访问,也就是互斥访问资源。

同步:多个进程或线程之间需要合作,相互之间交换信息,实现同步运作。

阅读全文 »

主要说下官网没有提到的方面以及一些细节,如何设置vercel环境变量,设置评论模板,设置回复邮件账号,重新发布vercel项目

阅读全文 »