Java知识点

1. 序列化

Serialization
Deserialization
import java.io.Serializable;
implements Serializable
import java.io.File
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

oos = new ObjectOutputStream(new FileOutputStream(new File(“xxx.txt”)));
oos.writeObject(ob);

import java.io.FileInputStream;
import java.io.ObjectInputStream;
ois = new ObjectInputStream(new FileInputStream(new File(“xxx.txt”)));

2. static

  • 成员变量
  • 成员函数
  • 代码
  • 内部类
  • import static

3. synchronized

类锁
对象锁
monitor 对象
monitorEnter
monitorExit

4. volatile

可见性
有序性
无原子性

5. transient

临时变量

6.lock

ReentrantLock
import java.util.concurrent.

可重入锁
范围可控、trylock、性能

7. AtomicInteger

import java.util.concurrent.atomic.AtomicInteger

a.getAndIncrement();

8.AtomicReference

import java.util.concurrent.atomic.AtomicReference

AtomicReference ao = new AtomicReference<>(new Object());
ao.set();
ao.get()
ao.compareAndSet(compareObject, newObject);

9. Thread

import java.lang.Thread
import java.lang.Runnable;

new Thread(runnableObject).start();

@Override
void run(){
}

Thread.currentThread.getId
getName/setName
getPriority/setPriority
isDaemon/setDaemon 守护进程依赖其创建的进程
Thread.currentThread.sleep();
Thread.currentThread.yield() 释放cpu
isInterrupted/interrupt
join 等待其完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值