llgd.net
当前位置:首页 >> 线程号打印 >>

线程号打印

#include #include #include #include #include #define THREAD_NUM 3 void * thread_handler(void *arg); void main() { int i; pthread_t tid[THREAD_NUM]; for(i = 0; i < THREAD_NUM; i++){ pthread_create(&tid[i], NULL, thread_handler, ...

一个一个回答你 1、其中pool-1-thread-18代表的是当前线程的名字吗? 答:是线程名,这个名字是它自己命的名,不用管 2、18代表的是什么? 答:就是排在18号位置上得线程 3、为什么我线程池最大数量为30,却可以得到pool-1-thread-168这样的输出...

public class Test { int count = 0; public static void main(String[] args) { Test test = new Test(); MyThread thread1 = new MyThread(test); MyThread thread2 = new MyThread(test); MyThread thread3 = new MyThread(test); new Thread...

Thread.currentThread().getId(); 可以得到线程id

你要的是这样的效果? class Demo implements Runnable {private int ticket = 10;public void run() {while (ticket > 0) {System.out.println(Thread.currentThread().getName() + "开始卖票,剩余张数:" + ticket);ticket--;}}}public class...

你先要告诉大家,你想用什么语言实现啊!

public class TestThread { private static String status = "A"; public static void main(String[] args) { new Thread(new Runnable() { @Override public void run() { int count=10; for(int i=0;i

帮你改了改,测试可行 public class ThreadTest1 extends Thread { private static int num = 0, n = 100; static ThreadTest1 t1, t2; static int i = 0; static int x; static String ss = new String(); public ThreadTest1() { start(); } p...

package com.myThread;public class TestMain { public static Object object = new Object();//共享资源 public static boolean flag = true;//判断是否线程要结束 public static void main(String[] args) { Thread t1 = new Thread(new Threa...

这个就是多线程的一个考察: public class RunTest { public static void main(String[] args) { Myprint mp = new Myprint(); new Capital(mp).start(); new Lowercase(mp).start();}}class Myprint { boolean flag = true; int i = 0; int j =...

网站首页 | 网站地图
All rights reserved Powered by www.llgd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com