JAVA Java多线程与并发库

Java多线程与并发库

同步方式
import javax.xml.stream.events.StartDocument;public class TestSynchronized {public static void main(String[] args) {// TODO Auto-generated method stubTestSynchronized test = new TestSynchronized();test.init();}void init() {final Outputer outputer = new Outputer();new Thread(new Runnable(){@Overridepublic void run() {// TODO Auto-generated method stubwhile(true){try {Thread.sleep(10);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}outputer.Output("wangyuyuyuyuyuyuyuyu");}}}){}.start();new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubwhile(true){try {Thread.sleep(10);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}outputer.Output("zhouzhanzhaozhaozhaozhao");}}}){}.start();}class Outputer{final static String lockKey = "lock";//定义输出函数//第一种方式,提供某个锁public void Output(String name){int len = name.length();synchronized (lockKey) {for (int i = 0; i < len; i++){System.out.print(name.charAt(i));}System.out.println();}}//第二种方式,锁住自己public void Output1(String name){int len = name.length();synchronized (this) { //也可以用Outputer.classfor (int i = 0; i < len; i++){System.out.print(name.charAt(i));}System.out.println();}}//第三种方式,函数前面加关键字synchronizedpublic synchronized void Output2(String name){int len = name.length();for (int i = 0; i < len; i++){System.out.print(name.charAt(i));}System.out.println();}}}
定时器Timer
import java.util.Timer;
import java.util.TimerTask;public class TimerTest {public static void main(String[] args){new Timer().schedule(new TimerTask(){@Overridepublic void run() {// TODO Auto-generated method stubSystem.out.println("boom");}}, 3000);}
}
HashMap存储线程
import java.util.HashMap;
import java.util.Map;
import java.util.Random;public class TestThreadMap {private static HashMap<Thread, Integer> map = new HashMap<Thread, Integer>();public static void main(String[] args) {//TestThreadMap testThreadMap = new TestThreadMap();for (int i = 0; i < 2; i++) {new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubint data = new Random().nextInt();map.put(Thread.currentThread(), data);new A().Get();new B().Get();}}){}.start();}}static class A{public void Get(){int data = map.get(Thread.currentThread());System.out.println("A from " + Thread.currentThread().getName() + " get data " + data);}}static class B{public void Get(){int data = map.get(Thread.currentThread());System.out.println("B from " + Thread.currentThread().getName() + " get data " + data);}}
}
ThreadLocal类似HashMap存储线程
import java.util.HashMap;
import java.util.Map;
import java.util.Random;public class TestThreadMap {private static HashMap<Thread, Integer> map = new HashMap<Thread, Integer>();public static void main(String[] args) {//TestThreadMap testThreadMap = new TestThreadMap();for (int i = 0; i < 2; i++) {new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubint data = new Random().nextInt();map.put(Thread.currentThread(), data);new A().Get();new B().Get();}}){}.start();}}static class A{public void Get(){int data = map.get(Thread.currentThread());System.out.println("A from " + Thread.currentThread().getName() + " get data " + data);}}static class B{public void Get(){int data = map.get(Thread.currentThread());System.out.println("B from " + Thread.currentThread().getName() + " get data " + data);}}
}
import java.util.Random;public class TestThreadlocal_2 {public static void main(String[] args) {// TODO Auto-generated method stubfor (int i = 0; i < 2; i++){new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubint data = new Random().nextInt();MyData.getInstance().setName("myData" + data);MyData.getInstance().setAge(data);new A().Get();new B().Get();}}){}.start();}}static class A{public void Get(){MyData data = MyData.getInstance();System.out.println("A from " + Thread.currentThread().getName() + " get data " + data.getName() + ", " + data.getAge());}}static class B{public void Get(){MyData data = MyData.getInstance();System.out.println("B from " + Thread.currentThread().getName() + " get data " + data.getName() + ", " + data.getAge());}}}class MyData{String name;int age;public static /*synchronized*/ MyData getInstance(){MyData instance = threadLocal.get();if (instance == null){  //不存在就创建一个与本线程有关的实例对象instance = new MyData();threadLocal.set(instance);}return instance;}//private static MyData instance = null;private static ThreadLocal<MyData> threadLocal = new ThreadLocal<MyData>();public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}}
线程池
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;public class TestThreadPool {public static void main(String[] args){//固定大小的线程池ExecutorService threadPool = Executors.newFixedThreadPool(3);//缓存线程池,当线程不够用时会自动增加,多了会自动减少//ExecutorService threadPool = Executors.newCachedThreadPool();//单一线程池,线程死了可以重新启动//ExecutorService threadPool = Executors.newSingleThreadExecutor();for (int i = 1; i <= 10; i++){final int taskid = i;threadPool.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubfor (int j = 1; j <= 10; j++) {System.out.println(Thread.currentThread().getName() + " is loop of " + j + " for task of " + taskid);}}});}System.out.println("all have finished");threadPool.shutdown(); //线程池里没有任务了,线程池才关闭,等10个任务都完成后才关闭//threadPool.shutdownNow(); //一个线程完成之后立马关闭,此时只完成了3个任务/*//定时器线程池Executors.newScheduledThreadPool(3).schedule(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubSystem.out.println("booming");}}, 6,TimeUnit.SECONDS); //多长时间后执行任务
*/        Executors.newScheduledThreadPool(3).scheduleAtFixedRate( //以固定频率执行任务new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubSystem.out.println("booming");}}, 6,  //初始时间2,  //间隔时间TimeUnit.SECONDS);}
}
锁Lock
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;import javax.xml.stream.events.StartDocument;public class TestLock {public static void main(String[] args) {// TODO Auto-generated method stubTestLock test = new TestLock();test.init();}void init() {final Outputer outputer = new Outputer();new Thread(new Runnable(){@Overridepublic void run() {// TODO Auto-generated method stubwhile(true){try {Thread.sleep(10);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}outputer.Output("wangyuyuyuyuyuyuyuyu");}}}){}.start();new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubwhile(true){try {Thread.sleep(10);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}outputer.Output("zhouzhanzhaozhaozhaozhao");}}}){}.start();}class Outputer{Lock lock = new ReentrantLock(); //锁public void Output(String name){int len = name.length();lock.lock();try {for (int i = 0; i < len; i++){System.out.print(name.charAt(i));}System.out.println("");} finally{// TODO: handle exceptionlock.unlock();}}}}
读写锁ReadWriterLock
import java.util.HashMap;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;public class TestReadWriterLock {HashMap<String, Object> mp = new HashMap<String, Object>();private ReadWriteLock rwl = new ReentrantReadWriteLock();public Object Get(String key){rwl.readLock().lock();Object value = null;try {value = mp.get(key);if (value == null) {rwl.readLock().unlock();rwl.writeLock().lock();try {if (value == null){value = "aaa";}} finally {// TODO: handle finally clauserwl.writeLock().unlock();}rwl.readLock().lock();}} finally {rwl.readLock().unlock();}return value;}
}
信号灯Semaphere(控制当前运行的线程个数)
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.function.IntToDoubleFunction;public class TestSemaphere {public static void main(String[] args) {// TODO Auto-generated method stub/*1.创建线程池*2.创建信号灯,大小为3 *3.循环10次,Runnable里设置信号灯acqure*/ExecutorService es = Executors.newCachedThreadPool();Semaphore semaphore = new Semaphore(3);for(int i = 0; i < 10; i++){es.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {semaphore.acquire();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}System.out.println("线程" + Thread.currentThread().getName() + "进入");try {Thread.sleep((int)Math.random() * 10000);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}System.out.println("线程" + Thread.currentThread().getName() + "即将结束");semaphore.release();System.out.println("线程" + Thread.currentThread().getName() + "已结束");es.shutdown();}});}}}
数据交换Exchanger(当两个数据都到达后才能进行交换,否则阻塞)
import java.util.concurrent.Exchanger;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;public class TestExchanger {public static void main(String[] args) {// TODO Auto-generated method stubExecutorService es = Executors.newCachedThreadPool();Exchanger<String> exchanger = new Exchanger<String>();es.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {String data1 = "x";System.out.println("线程" + Thread.currentThread().getName() + "正在把数据" + data1 + "发送出去");Thread.sleep((int)(Math.random() * 5000));String getData = exchanger.exchange(data1);System.out.println("线程" + Thread.currentThread().getName() + "接受到的数据为: " + getData);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}});es.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {String data1 = "y";System.out.println("线程" + Thread.currentThread().getName() + "正在把数据" + data1 + "发送出去");Thread.sleep((int)(Math.random() * 5000));String getData = exchanger.exchange(data1);System.out.println("线程" + Thread.currentThread().getName() + "接受到的数据为: " + getData);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}});}}
同步屏障CyclicBarrier(多个线程彼此等待,集合后再往后运行)
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;public class TestCyclicBarrier {//多个线程彼此等待,集合后再运行public static void main(String[] args) {// TODO Auto-generated method stub//创建线程池和CyclicBarrier,同时运行多个线程,调用awaitExecutorService es = Executors.newCachedThreadPool();final CyclicBarrier cb = new CyclicBarrier(3);for (int i = 0; i < 3; i++){es.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep((int)(Math.random() * 1000));System.out.println("线程" + Thread.currentThread().getName() + "到达集合点1");System.out.println("当前有" + (cb.getNumberWaiting()+1) + "人在等待");cb.await();Thread.sleep((int)(Math.random() * 1000));System.out.println("线程" + Thread.currentThread().getName() + "到达集合点2");System.out.println("当前有" + (cb.getNumberWaiting()+1) + "人在等待");cb.await();Thread.sleep((int)(Math.random() * 1000));System.out.println("线程" + Thread.currentThread().getName() + "到达集合点3");System.out.println("当前有" + (cb.getNumberWaiting()+1) + "人在等待");cb.await();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}});}es.shutdown();}}
CountDownLatch(类似倒计时计数器,当计数减为0时,所有等待者才开始执行)
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;public class TestCountDownLatch {//类似倒计时计数器,当计数减为0的时候,所有等待者才开始执行public static void main(String[] args) {// TODO Auto-generated method stub//创建两个计数器,一个为1,一个为3,代表一个裁判员,三个运动员,裁判员在未下达命令前运动员等待,下达命令后才执行//等三个运动员都到达终点后,裁判员才公布成绩ExecutorService es = Executors.newCachedThreadPool();CountDownLatch cdOrder = new CountDownLatch(1);CountDownLatch cdAnswer = new CountDownLatch(3);for (int i = 0; i < 3; i++) {final int id = i;es.execute(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {System.out.println("运动员" + id + "正准备接受命令");cdOrder.await();System.out.println("运动员"+ id + "接受到命令");Thread.sleep((int)(Math.random() * 5000));System.out.println("运动员" + id + "到达终点");cdAnswer.countDown();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}});}try {Thread.sleep(1000);System.out.println("裁判员发出指令");cdOrder.countDown();System.out.println("裁判员等待所有运动员到达终点");cdAnswer.await();System.out.println("裁判员公布成绩");} catch (Exception e) {// TODO: handle exception}}}
Callable和Future
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;public class TestCallableAndFuture {public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException{ExecutorService threadPool = Executors.newSingleThreadExecutor();Future future =threadPool.submit(new Callable<String>() {@Overridepublic String call() throws Exception {// TODO Auto-generated method stubThread.sleep(2000);return "hello";}});System.out.println("得到结果: " + future.get()); //callable完成任务返回结果,由future去拿,需要等待一段时间//System.out.println("得到结果: " + future.get(1, TimeUnit.SECONDS)); //要在规定的时间内得到结果,如果得不到就抛出异常//CompletionService 用于提交一组callable任务,并用take方法得到一个已完成任务的future对象ExecutorService threadPool2 = Executors.newFixedThreadPool(10);CompletionService<Integer> completionService = new ExecutorCompletionService<Integer>(threadPool2);for (int i = 1; i <= 10; i++){final int taskid = i;completionService.submit(new Callable<Integer>() {@Overridepublic Integer call() throws Exception {// TODO Auto-generated method stubtry {Thread.sleep(new Random().nextInt(5000));} catch (Exception e) {// TODO: handle exception}return taskid;}});}for (int i = 1; i <= 10; i++){System.out.println(completionService.take().get());}}}
阻塞队列ArrayBlockingQueue
import java.util.concurrent.ArrayBlockingQueue;public class TestArrayBlockingQueue {//阻塞队列当队列为空时take会阻塞,当队列满时put会阻塞//用两个阻塞队列模拟两个线程交替运行//两个阻塞队列大小均设置为1,其中一个放一个数据public static void main(String[] args) {// TODO Auto-generated method stubBusiness business = new Business();new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubfor (int j = 1; j <= 10; j++) {business.Sub(j);}}}){}.start();for (int j = 1; j <= 10; j++) {business.Main(j);}}static class Business{ArrayBlockingQueue abq1 = new ArrayBlockingQueue(1);ArrayBlockingQueue abq2 = new ArrayBlockingQueue(1);public Business() {try {abq2.put(1);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}public void Sub(int j){try {abq1.put(1);for (int i = 1; i <= 10; i++){System.out.println("sub thread " + i + " of loop " + j);}abq2.take();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}public void Main(int j){try {abq2.put(1);for (int i = 1; i <= 10; i++){System.out.println("main thread " + i + " of loop " + j);}abq1.take();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}}}
练习: 子线程运行10次,主线程运行20次,交替运行
public class prictice_1 {//子线程运行10次,主线程运行20次public static void main(String[] args) {// TODO Auto-generated method stubBusiness business = new Business();new Thread(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubfor (int j = 1; j <= 10; j++) {business.Sub(j);}}}){}.start();for (int j = 1; j <= 10; j++) {business.Main(j);}}}
class Business{private boolean isSub = true;public synchronized void Sub(int j){while (!isSub) {try {this.wait();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}for (int i = 1; i <= 10; i++){System.out.println("sub thread " + i + " of loop " + j);}isSub = false;this.notify();}public synchronized void Main(int j){while (isSub){try {this.wait();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}}for (int i = 1; i <= 20; i++){System.out.println("main thread " + i + " of loop " + j);}isSub = true;this.notify();}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/309846.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[C++11]统一的数据初始化方式 - 初始化列表

关于C中的变量&#xff0c;数组&#xff0c;对象等都有不同的初始化方法&#xff0c;在这些繁琐的初始化方法中没有任何一种方式适用于所有的情况。为了统一初始化方式&#xff0c;并且让初始化行为具有确定的效果&#xff0c;在C11中提出了列表初始化的概念。 代码如下: #in…

ffmpeg为何用c语言编译,如何使用ffmpeg的c语言sdk实现对文件夹的操作

重要函数打开文件夹&#xff1a;avio_open_dir()读取文件夹&#xff1a;avio_read_dir()关闭文件夹&#xff1a;avio_close_dir()结构体, 操作目录的上下文&#xff1a;AVIODirContext()目录项&#xff0c;用于存放文件名&#xff0c;文件大小等信息&#xff1a;AVIODirEntry()…

Sql Server之旅——第三站 解惑那些背了多年聚集索引的人

说到聚集索引&#xff0c;我想每个码农都明白&#xff0c;但是也有很多像我这样的伪程序员&#xff0c;只能用死记硬背来解决这个问题&#xff0c;什么表中只能建一个聚集索引&#xff0c;然后又扯到了目录查找来帮助读者记忆。。。。问题就在这里&#xff0c;我们不是学文科&a…

C#相关基础知识点总结+基础代码

C#基础知识 同一命名空间下的两个类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace HelloWorld {class A{private int a;public A(int x) { a x; }public void show() { Console.WriteL…

[PAT乙级]1038 统计同成绩学生

本题要求读入 N 名学生的成绩&#xff0c;将获得某一给定分数的学生人数输出。 输入格式&#xff1a; 输入在第 1 行给出不超过 10​5​​ 的正整数 N&#xff0c;即学生总人数。随后一行给出 N 名学生的百分制整数成绩&#xff0c;中间以空格分隔。最后一行给出要查询的分数个…

懂「互联网语」的程序员,是个狠人。

借用一下时下很火的「互联网语」做程序员的乐趣是只有进场的人才能获得的红利与程序员相处绝对是令人WOW的用户体验但是别真信那些个程序员说的话哪怕有无数江湖传言为他背书不然你良久建立的心智模型会在瞬间就崩塌毕竟头部程序员和腰腿部程序员之间的壁垒打通不了也许你暂时还…

综合知识点+计算机

综合知识点 多态性有哪些&#xff1f;&#xff08;静态和动态&#xff0c;分别叙述了一下虚函数和函数重载&#xff09; { 分为静态多态性和动态多态性&#xff0c;静态就是在编译时就已经确定了&#xff0c;动态是在程序运行时 才能确定。像函数重载&#xff0c;就是多个函数…

[PAT乙级]1036 跟奥巴马一起编程

美国总统奥巴马不仅呼吁所有人都学习编程&#xff0c;甚至以身作则编写代码&#xff0c;成为美国历史上首位编写计算机代码的总统。2014 年底&#xff0c;为庆祝“计算机科学教育周”正式启动&#xff0c;奥巴马编写了很简单的计算机代码&#xff1a;在屏幕上画一个正方形。现在…

c语言oj合法标识符,YTUOJ-C语言合法标识符

Description输入一个字符串&#xff0c;判断其是否是C的合法标识符。Input输入数据包含多个测试实例&#xff0c;数据的第一行是一个整数n,表示测试实例的个数&#xff0c;然后是n行输入数据&#xff0c;每行是一个长度不超过50的字符串。Output对于每组输入数据&#xff0c;输…

[C++11]initializer_lisr模板类的使用

代码如下: #include <iostream> using namespace std;void func(initializer_list<int> ls) {auto it ls.begin();for (; it ! ls.end(); it){cout << *it << " ";}cout << endl; }int main() {func({ 1,2,5,12,23 });return 0; }测…

map的专项知识点总结

map的专项知识点总结 标准库map类型是一种以键-值(key-value)存储的数据类型。以下分别从以下的几个方面总结&#xff1a; &#xff08;1&#xff09;.map对象的定义和初始化 &#xff08;2&#xff09;.map对象的基本操作&#xff0c;主要包括添加元素&#xff0c;遍历等 m…

linux tcp 创建,Linux下tcp服务器创建的步骤

创建一个socket&#xff0c;使用函数socket()socket(套接字)实质上提供了进程通信的端点&#xff0c;进程通信之前&#xff0c;双方首先必须建立各自的一个端点&#xff0c;否则没有办法通信。通过socket将IP地址和端口绑定之后&#xff0c;客户端就可以和服务器通信了#include…

基于 abp vNext 和 .NET Core 开发博客项目 - 数据访问和代码优先

上一篇文章完善了项目中的代码&#xff0c;接入了Swagger。本篇主要使用Entity Framework Core完成对数据库的访问&#xff0c;以及使用Code-First的方式进行数据迁移&#xff0c;自动创建表结构。数据访问在.EntityFrameworkCore项目中添加我们的数据访问上下文对象MeowvBlogD…

[C++11]使用using和typedef给模板定义别名

using语法和typedef一样&#xff0c;并不会创建出新的类型&#xff0c;它们只是给某些类型定义了新的别名。using相较于typedef的优势在于定义函数指针别名时看起来更加直观&#xff0c;并且可以给模板定义别名。 使用typedef给模板定义别名: 无法直接使用typedef给模板定义别…

石家庄学院c语言试题,谁会高级语言程序设计?要求用C语言,帮帮我把,愁死我啦...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼好的&#xff0c;题目如下&#xff0c;帮我做做吧1. 图形时钟功能要求&#xff1a;在屏幕上显示一个图形时钟(用程序绘制一个与时钟样式相似即可)&#xff0c;时间与系统时间一致&#xff0c;且要随着时间的走动准确的走动。2. 万年…

Shaolin HDU - 4585(map模板题)

题意&#xff1a; 少林寺有n1个和尚&#xff0c;他们都有一个独有的编号和战斗力值&#xff0c;当一个年轻人通过所有考试并被宣布为少林的新僧人时&#xff0c;将会有一场战斗&#xff0c;作为欢迎的一部分。新和尚必须与一位战斗等级最接近他的战斗等级的老和尚战斗。如果有…

Azure Show|第一期 开播啦!嘉宾梁迪李卓恒李佳芮

欢迎来到Azure Show!Azure ShowAzure Show 是由微软最有价值专家、微软技术社区区域总监卢建晖和微软开发者关系PM朱兴亮共同发起的一个关于微软Azure、开源技术、还有技术社区相关的线上节目。每期节目由MVP面对面、开源故事、从零开始以及Azure101组成&#xff0c;邀请微软技…

c语言coin函数库,Coin Test | C/C++程序员之家

Coin Test时间限制&#xff1a;3000 ms | 内存限制&#xff1a;65535 KB难度&#xff1a;1描述As is known to all,if you throw a coin up and let it droped on the desk there are usually three results. Yes,just believe what I say ~it can be the right side or the …

[PAT乙级]1033 旧键盘打字(getline()读入)

旧键盘上坏了几个键&#xff0c;于是在敲一段文字的时候&#xff0c;对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键&#xff0c;打出的结果文字会是怎样&#xff1f; 输入格式&#xff1a; 输入在 2 行中分别给出坏掉的那些键、以及应该输入的文字。其…

基于 abp vNext 和 .NET Core 开发博客项目 - 完善与美化,Swagger登场

上一篇文章(https://www.cnblogs.com/meowv/p/12896898.html)已经成功将博客项目跑起来了&#xff0c;那么本篇主要是将之前遗留的问题解决&#xff0c;现在的代码看起来可能还是比较混乱&#xff0c;有大量与之无关的代码存在里面&#xff0c;对于强迫症患者来说真的是零容忍。…