只有MacOS环境可以怎么验证呢
private void capacity(){ //数组初始化 if (this.arr==null){ this.arr=new Object[this.stackLength]; } //1。5倍扩容 if (this.size-this.stackLength==0){ this.stackLength = this.stackLength+(this.stackLength>>1); this.arr = Arrays.copyOf(this.arr,this.stackLength); } }
老师,我扩容这么写可以吗
com.bjsxtsun.awt.windows.ThemeReaderDaemonThreadDemo { (String[] args) InterruptedException { Thread t = Thread(Daemon())t.setDaemon()t.start()Thread.()System..println()Thread t2 = Thread(UsersThread())t2.start()} } Daemon Runnable{ () { (i = i <i++) { System..println(Thread.().getName()++i){ Thread.()} (InterruptedException e) { e.printStackTrace()} } System..println()} } UsersThread Runnable{ () { Daemon daemon = Daemon()Thread t1 = Thread(daemon)t1.setDaemon()t1.start()(i = i <i++) { System..println(Thread.().getName()++i){ Thread.()} (InterruptedException e) { e.printStackTrace()} } } }
测试结果:
Daemon 0Daemon 1Daemon 2Daemon 3主线程结束UserThread 0DaemonUsers 0UserThread 1Daemon 4DaemonUsers 1UserThread 2UserThread 3Daemon 5UserThread 4DaemonUsers 2UserThread 5Daemon 6UserThread 6DaemonUsers 3UserThread 7Daemon 7UserThread 8DaemonUsers 4UserThread 9Daemon 8DaemonUsers 5
老师 为什么我这里测出来的守护线程的消亡是在用户线程结束后结束的 而不是跟随主线程的结束而结束
我可以用set嘛,这样直接是不重复的
bjsxt.zip
怎么会报空指针呢,想不明白
public class Reach { public static void main(){ System.out.println("测试提问,无须回答!"); } }
测试提问,无须回答,谢谢。
老师,请问CALALINA_HOME的路径加什么,视频里面看不到路径后面的内容
老师,请问这里的唤醒线程的"abc"是必须与上面synchronized("abc")一样吗
老师我想问一下为啥这里不加else会报错啊?
老师,这个不是字符串转为整型对象吗?
为啥他可以直接当一个整型数字使用?(是因为这个范围内的数字可以自动拆箱吗?)
老师,用eclipse打开课程的源码怎么打开?
打印出来为什么是字母隔断两个呢?逻辑有问题?
Printer:
package cn.sxt.thread; public class Printer { private int index=1; public synchronized void print(int number) throws InterruptedException{ if(index%3==0){ super.wait(); }else{ System.out.println(number); super.notifyAll(); index++; } } public synchronized void print(char ch) throws InterruptedException{ if(index%3!=0){ super.wait(); }else{ System.out.println(ch); super.notifyAll(); index++; } } }
CharPrinter:
package cn.sxt.thread; public class CharPrinter implements Runnable { private Printer printer; public CharPrinter(Printer printer){ this.printer=printer; } @Override public void run() { for(char i='A';i<='Z';i++){ try { printer.print(i); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
NumberPrinter :
package cn.sxt.thread; public class NumberPrinter implements Runnable { private Printer printer; public NumberPrinter(Printer printer){ this.printer=printer; } @Override public void run() { for(int i=1;i<=52;i++){ try { printer.print(i); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
TestThread
package cn.sxt.thread; public class TestThread { public static void main(String[] args){ Printer p = new Printer(); NumberPrinter np = new NumberPrinter(p); CharPrinter cp = new CharPrinter(p); Thread t1 = new Thread(np); Thread t2 = new Thread(cp); t1.start(); t2.start(); } }
MyNewThread.rar
package com.zzh; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MyArrayList { public static void test(){ List<String> list =new ArrayList<String>(); System.out.println(list.isEmpty()); list.add("1"); System.out.println(list.isEmpty()); list.add("2"); list.add("3"); System.out.println(list); System.out.println("list的大小:"+list.size()); list.remove("1"); System.out.println(list); System.out.println(list); System.out.println("获取其中一个元素: " + list.get(2)); Object[] objs = list.toArray(); System.out.println("转换成Object数组:"+Arrays.toString(objs)); list.clear(); } public static void main(String[] args) { test(); } }
结果:
这是为什么
前面的问题已解决!文件权限问题,根据报错信息修改了对应的log文件夹和work文件夹的权限就好了。win10这一点比较麻烦。
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637