print('操作码:%d,ACK:%d,服务器随机端口:%d,数据长度:%d' % (caozuoma, ack_num, rand_port, len(recv_data[0])))
老师,这里的%符号没有理解,是什么意思?
请问老师,为什么一定要写这行代码,要不然就报错。
找到原因了……应该是t.start()~~~~~~~~~~
package com.bjsxt.homework.Thread; public class JoinThread { public static void main(String[] args) { System.out.println("main线程开始"); Thread t1 = new Thread(new A()); t1.start(); //new B().start(); for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行"+i); //i=3时,main被挂起,直到A执行完。 if (i == 3) { try { t1.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } System.out.println("main线程结束"); } } class A implements Runnable{ Thread t = new B(); @Override public void run() { t.run(); for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行"+i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } //i=5时,A被挂起,直到B执行完。 if(i==5){ try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } } }} } class B extends Thread{ @Override public void run() { for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行!!!"+i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
老师好,请问为什么这个程序里的“public static main(String[] args){}”里不加“static”,程序就没有运行的那个绿色的小按钮呢
Recur { (i){ (i==){ }{ i*(i-)} } (String[] args) { sum = (j = j<=j++){ sum = sum + (j)} System..println(sum)} }
com.bjsxt.homework.Thread; JoinThread { main(String[] args) { System..println(); Thread t1 = Thread(A()); t1.start(); (i =;i<;i++){ System..println(Thread.().getName()++i); (i == ) { { t1.join(); } (InterruptedException e) { e.printStackTrace(); } } } System..println(); } } A Runnable{ Thread = B(); run() { .run(); (i =;i<;i++){ System..println(Thread.().getName()++i); { Thread.(); } (InterruptedException e) { e.printStackTrace(); } (i==){ { .join(); } (InterruptedException e) { e.printStackTrace(); } } }} } B Thread{ run() { (i =;i<;i++){ System..println(Thread.().getName()++i); { Thread.(); } (InterruptedException e) { e.printStackTrace(); } } } }
代码:
运行结果:main线程开始main正在运行0main正在运行1main正在运行2main正在运行3Thread-1正在运行!!!0Thread-1正在运行!!!1Thread-1正在运行!!!2Thread-1正在运行!!!3Thread-1正在运行!!!4Thread-1正在运行!!!5Thread-1正在运行!!!6Thread-1正在运行!!!7Thread-1正在运行!!!8Thread-1正在运行!!!9Thread-1正在运行0Thread-1正在运行1Thread-1正在运行2Thread-1正在运行3Thread-1正在运行4Thread-1正在运行5Thread-1正在运行6Thread-1正在运行7Thread-1正在运行8Thread-1正在运行9main正在运行4main正在运行5main正在运行6main正在运行7main正在运行8main正在运行9main线程结束Process finished with exit code 0
请问为什么线程中不能创建线程呢???只有一个Thread1
select e.ename,e.job,m.ename,m.job from emp m right join emp e on e.mgr=m.empno select e.ename,e.job,m.ename,m.job from emp e right join emp m on e.mgr = m.empno
老师,这两段代码执行起来为什么结果是不同的,不管是左连接还是右连接,emp都是同一个表 ,后面的e和m只是给这个表起个别名,为什么结果确实不一样的
test01不能生成表怎么办
微信图片_20210507133031.png
微信图片_20210507132339.png
老师 我在maven整合完成ssm框架后,使用jQuery时报错org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping for GET /js/jquery.js
mybatisDemo.zip
老师,找不到错误,帮我看下
老师,麻烦解答一下,我的程序没有错,第一次运行图片显示损毁,再次运行显示程序在跑,但是tftpd已经显示传输完成了,我在没有改动的前提下,关闭pycharm后再次运行就成功了,这是为什么尼,谢谢
老师今天是星期五,怎么他显示是这个星期第6天了啊?
/** * 定义馒头类 */ class mantou2{ private int id ; public int getId() { return id; } public void setId(int id) { this.id = id; } public mantou2(int id) { this.id = id; } } /** * 定义缓冲区 */ class buffer{ private mantou2[] mt = new mantou2[10]; private int index ; /** * 放馒头 */ public synchronized void push(mantou2 mantou2){ while (this.index == this.mt.length){ try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } notify(); this.mt[index] = mantou2 ; index++ ; } /** * 取馒头 */ public synchronized mantou2 pop(){ while (this.index == 0){ try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } notify(); this.index--; return this.mt[index] ; } } /** * 取馒头线程 */ class qumantou extends Thread{ buffer buffer = new buffer(); public qumantou(com.itbz.buffer buffer) { this.buffer = buffer; } @Override public void run() { for (int i = 0; i < 10;i++){ buffer.pop() ; System.out.println("取馒头" + i); } } } /** * 放馒头线程 */ class cunmantou extends Thread{ buffer buffer = new buffer(); public cunmantou(com.itbz.buffer buffer) { this.buffer = buffer; } @Override public void run() { for (int i = 0; i < 10;i++){ System.out.println("存馒头" + i); mantou2 mantou2 = new mantou2(i); buffer.push(mantou2); } } } public class ProductThread2 { public static void main(String[] args) { buffer buffer = new buffer(); cunmantou cunmantou = new cunmantou(buffer); qumantou qumantou = new qumantou(buffer); cunmantou.start(); qumantou.start(); } }
问题 在主方法中声明两个存取馒头的时候,要对存取馒头两个类进行增加有参构造方法而不能使用默认无参构造方法才能正常,如果使用无参构造方法时,程序会阻塞?为什么?这块不太理解
老师,这两个有什么区别,作用是相同的嘛?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637