摘要: 前端代码 import wx import socket import threading import random from wx import TE_MULTILINE class chatFrame(wx.Frame): def __init__(self,nickname): super( 阅读全文
posted @ 2025-12-19 11:53 xdhking 阅读(7) 评论(0) 推荐(0)
摘要: Task.hpp: #include<functional> class Task{ public: using func_t=std::function<std::string(int,int,char)>; Task(){} Task(const func_t &fun,const int &x 阅读全文
posted @ 2025-11-04 20:12 xdhking 阅读(9) 评论(0) 推荐(0)
摘要: file: BlockQueue.hpp: #pragma once #include<pthread.h> #include<cassert> #include<queue> const int maxsize=5; template<class T> class BlockQueue{ publ 阅读全文
posted @ 2025-11-03 21:46 xdhking 阅读(10) 评论(0) 推荐(0)
摘要: 概念 1.多个执行流进行安全访问的共享资源——临界资源 2.多个执行流中,访问临界资源的代码——临界区--往往是线程代码的很小一部分 3.想让多个线程串行访问共享资源——互斥 4.对一个资源进行访问的时候,要么不做,要么做完——原子性 解决方案: 解决方案:加锁 互斥锁pthread_mutex_t 阅读全文
posted @ 2025-11-03 15:28 xdhking 阅读(46) 评论(0) 推荐(0)
摘要: //Thread.hpp #pragma once #include<iostream> #include<string> #include<cstring> #include<functional> #include<unistd.h> #include<cassert> #include<pth 阅读全文
posted @ 2025-11-02 20:47 xdhking 阅读(12) 评论(0) 推荐(0)
摘要: 错误方式: 创建第一个线程时,该线程来不及保存namebuffer的数据就切换到主线程 然后主线程修改namebuffer准备创建第二个线程,而导致前一个线程还未 保存的数据被第二个线程的数据所覆盖了,导致最后输出多个线程的内容一样 且有部分线程输出内容缺失 #include<iostream> # 阅读全文
posted @ 2025-11-01 11:26 xdhking 阅读(11) 评论(0) 推荐(0)
摘要: 洛谷P1345 假设原来的点编号为i,总共有n个点,那么我们就把每个点拆成两个点,编号分别为i和i+n。其中点i负责连接原图中连入这个点的边,点i+n负责连原图中连出这个点的边。 add ( i, i+n, 1 ) ; add ( i+n, i, 0 ) ; 对于原图中本来就存在的边,它们只是有一个 阅读全文
posted @ 2025-10-09 18:56 xdhking 阅读(11) 评论(0) 推荐(0)
摘要: 洛谷p4014 #include<bits/stdc++.h> using namespace std; const int N=120; const int M=N*N+(N<<1); struct edge{int v,c,w,ne;}e[M]; int h[N],id=1; int n,s,t 阅读全文
posted @ 2025-10-09 15:05 xdhking 阅读(20) 评论(0) 推荐(0)
摘要: #include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; #define LL long long #define N 510 #define INF 1e12 int n,m 阅读全文
posted @ 2025-10-08 21:14 xdhking 阅读(14) 评论(0) 推荐(0)
摘要: 洛谷P4926 [1007] 倍杀测量者 #include<bits/stdc++.h> using namespace std; const int N=1010; const double INF=1e18; const double eps=1e-7; struct node{ int v; 阅读全文
posted @ 2025-10-08 16:28 xdhking 阅读(12) 评论(0) 推荐(0)