咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

环境:Windows10下在WM中安装Linux
错误信息大概如下

1
vcpu-0:VERIFY vmcore/vmm/main/cpuid.c:382 bugNr=1036521

本来vm一直在正常运行,发生这次错误是在电脑(Windows10)的一次不正常关机(断电)之后。

cpu的相关设置记得没有改,vm有些功能是需要电脑开启虚拟cpu技术的(Intel virtual technology),这在装wm的系统时已经开启过了,估计电脑不正常关机导致恢复默认值了。

在BIOS中找到 Intel virtual technology,将其设置为ENABLE就可以了。

阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14

<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="你好测试用例啊啊啊啊啊"
android:fontFamily="@font/square_pixel_16"
android:textSize="200sp"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"/>

Java的内存模型(JMM)规定了所有的变量都是存在于 主内存(RAM) 当中的,而每个线程都有自己的工作内存或者本地内存,线程对变量的所有操作都必须在自己的工作内存中进行,而不能直接对主内存操作,并且每个线程都不能访问其他线程工作内存或者本地内存

比如,在某个线程中对变量 i 的复制操作 i=1,改线程必须在本地内存中对 i 进行修改之后才能将其写入 主内存 之中。

Java内存模型(JMM)三大特性

一、原子性

所有操作都执行或者都不执行

阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Test {


public static void main(String[] args) {

System.out.println(Runtime.getRuntime().availableProcessors());
//testSingleThreadExecutor();
//testFixedThreadPool();
//testCachedThreadPool();
}




/**
* 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待
*/
public static void testFixedThreadPool(){
//因为线程池大小为3,每个任务输出index后sleep 2秒,所以每两秒打印3个数字。
//定长线程池的大小最好根据系统资源进行设置。如获取cpu核心数Runtime.getRuntime().availableProcessors()
ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
for (int i = 0; i < 10; i++) {
final int index = i;
fixedThreadPool.execute(new Runnable() {
public void run() {
try {
System.out.println(index);
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
}


/**
* 创建一个可缓存线程池,如果线程池长度超过处理需要,可灵活回收空闲线程,若无可回收,则新建线程。
*/
public static void testCachedThreadPool(){

ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
for (int i = 0; i < 10; i++) {
final int index = i;
try {
Thread.sleep(index * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
cachedThreadPool.execute(new Runnable() {
public void run() {
System.out.println(index);
}
});
}
}


/**
* 创建一个单线程化的线程池,它只会用唯一的工作线程来执行任务,保证所有任务按照指定顺序(FIFO, LIFO, 优先级)执行
*/
public static void testSingleThreadExecutor(){
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
for (int i = 0; i < 10; i++) {
final int index = i;
singleThreadExecutor.execute(new Runnable() {
public void run() {
try {
System.out.println(index);
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
}

/**
* 创建一个定长线程池,支持定时及周期性任务执行
*/
public static void testScheduledThreadPool(){


ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(5);
scheduledThreadPool.schedule(new Runnable() {
public void run() {
System.out.println("delay 3 seconds");
}
//延迟3秒执行
}, 3, TimeUnit.SECONDS);
//延迟1秒后每3秒执行一次。
//}, 3, TimeUnit.SECONDS);
}
}

1.standard 标准模式

每次启动都new一个实例

2.singleTop 栈顶复用模式(栈顶单例模式)

1
android:launchMode="singleTop"
  • 如果Activity实例处于任务栈栈顶,再启动相同的Activity不会new出一个实例,只会有一个实例。
  • 如果Activity实例存在任务栈不处于栈顶,和standard一样new实例。
阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-122-generic x86_64)

cn@cnserver:~$ sudo apt install snapd
[sudo] password for cn:
Reading package lists... Done
Building dependency tree
Reading state information... Done
snapd is already the newest version (2.47.1+18.04).
snapd set to manually installed.
The following packages were automatically installed and are no longer required:
aufs-tools cgroupfs-mount containerd.io docker-ce-cli libdumbnet1 libltdl7 pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
cn@cnserver:~$
cn@cnserver:~$
cn@cnserver:~$
cn@cnserver:~$ sudo snap install nextcloud
nextcloud 20.0.1snap1 from Nextcloud✓ installed

安装完就启动了,默认端口是80,访问IP:80即可。

Boa是一个只有大概60KB的WebServer,很适合运行在嵌入式硬件设备的Web服务。

在 X86-Ubuntu中安装Boa的日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ wget http://www.boa.org/boa-0.94.14rc21.tar.gz
$ tar zxvf boa-0.94.14rc21.tar.gz
$ cd boa-0.94.14rc21/
$ ls
aclocal.m4 config.guess configure contrib CREDITS examples extras Makefile.in src
CHANGES config.sub configure.in COPYING docs extra_macros.m4 install-sh README
$ ./configure
$ make
$ ls src/
access.c boa.c buffer.o compat.h defines.h get.o index_dir.o Makefile pipe.o range.o response.c signals.o util.c
access.h boa.h cgi.c config.c escape.c globals.h ip.c Makefile.in poll.c read.c response.o sublog.c util.o
alias.c boa_indexer cgi_header.c config.h escape.h hash.c ip.o mmap_cache.c queue.c read.o select.c sublog.o
alias.o boa.o cgi_header.o config.h.in escape.o hash.o log.c mmap_cache.o queue.o request.c select.o timestamp.c
boa buffer.c cgi.o config.o get.c index_dir.c log.o pipe.c range.c request.o signals.c timestamp.o
$ sudo mkdir /etc/boa
$ ls contrib/rpm/
boa.conf boa.init-redhat boa.init-suse boa.logrotate boa.spec
$ sudo cp contrib/rpm/boa.conf /etc/boa
$ sudo ./src/boa
[13/Oct/2020:02:37:06 +0000] No such group: nobody
[13/Oct/2020:02:37:06 +0000] log.c:53 (open_logs) - unable to open error log: No such file or directory
$ sudo mkdir /var/log/boa
$ sudo vim /etc/boa/boa.conf

#修改默认端口
Port 8080
#修改运行身份
User 0
Group 0
#html存放路径
DocumentRoot /www
$ sudo ./src/boa
$ ps -ef|grep boa
root 48727 1 0 11:00 pts/0 00:00:00 ./src/boa
$ netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -