老师,users类型是什么类型,是数据类型的一种吗,
ServerSocket对象创建后不用关闭吗,为什么只关闭Socket对象
老师,能讲解一下为什么第一次打印显示删除的不是c而是d吗
老师一个线程加入了守护线程它有什么用啊?
为什么不能直接在list中删除item?
这里的list不是将this.map2.get(parent) 的值赋给了它吗?
在list中删除item会对this.map2.get(parent)的结果产生影响吗?
list中删除item后 brother的值 和list 删除item 前的值不一样吗?
老师主线程如果不主动去让它进入阻塞状态它会自动结束的吗
我们课程中有子网掩码的讲解不?有链接不?????????????
用eclipse导出项目是压缩包,怎么解决?
老师,16对16取余是0,讲道理不是应该存在1前面吗,为什么这里还是假排序呢
在运行的时候这是不是创建了三个接收线程,如果三个接受线程同时收到消息,虽然说是互斥,但是收到的信息会不会覆盖掉前一个信息,导致其他三个客户端,出现接收不到的情况,如果都能接收到,是因为wait是优先执行的吗,还是我整个理解都是错误的,如果错误麻烦老师指正一下
老师,在方法中返回Object时,都是指返回目标方法的值吗
com.bjsxt.testjava.util.Calendarjava.util.GregorianCalendarjava.util.Scannerjava.text.ParseExceptionZuoYe { (String[] args) { System..println()Scanner scan=Scanner(System.)String date= scan.nextLine()System..println(+date)String[] str=date.split()year=Integer.(str[])month=Integer(str[])day=Integer(str[])Calendar c=GregorianCalendar(yearmonth-day)c.set(Calendar.)down=c.get(Calendar.)System..println()(i=i<down-i++){ System..print()} maxDate=c.getActualMaximum(Calendar.)(i=i<=maxDatei++){ StringBuilder sBuilder=StringBuilder()(c.get(Calendar.)==day){ sBuilder.append(c.get(Calendar.)+)} { sBuilder.append(c.get(Calendar.)+)} System..print(sBuilder)(c.get(Calendar.)==Calendar.){ System..print()} c.add(Calendar.)} } }
月份是0-11,那么不应该加1这里
这句代码什么意思,在这个日历中起到什么作用
老师我这样写电脑里可以生成一条记录
/** * 添加新纪录 */ public void addOperation(){ //创建对象 ObjectOutputStream oos=null; TelNoteRegex telNoteRegex=new TelNoteRegex(); String name=telNoteRegex.nameValidate(); String age=telNoteRegex.ageValidate(); String sex=telNoteRegex.sexValidate(); String telNum=telNoteRegex.telNumValidate(); String address=telNoteRegex.addressValidate(); Person person=new Person(name,age,sex,telNum,address); this.list.add(person); try{ oos=new ObjectOutputStream(new FileOutputStream("d:/电话本记录.txt")); oos.writeObject(list); }catch (Exception e){ e.printStackTrace(); }finally { try{ if(oos!=null) { oos.close(); } }catch (Exception e){ e.printStackTrace(); } } person.setId(this.list.size()); }
但是反序列的时候在控制台打印不出记录
/** * 查询全记录 */ public void showAll(){ //反序列化 ObjectInputStream ois=null; try{ ois=new ObjectInputStream(new FileInputStream("d:/电话本记录.txt")); List list= (List)ois.readObject(); if(this.list.size()==0) { System.out.println("没有任何记录"); return; } for(int i=0;i<this.list.size();i++) { System.out.println(this.list.get(i)); } }catch (Exception e){ e.printStackTrace(); }finally { try{ if(ois!=null) { ois.close(); } }catch (Exception e){ e.printStackTrace(); } } }
/** *定义馒头类 */ class ManTou{ private int id; public ManTou(int id){ this.id = id; } public int getId(){ return this.id; } } /** *定义缓冲区类 */ class SyncStack{ //定义存放馒头的盒子 private ManTou[] mt = new ManTou[10]; //定义操作盒子的索引 private int index; /** *放馒头 */ public synchronized void push(ManTou manTou){ //判断盒子是否已满 while(this.index == this.mt.length){ try { /** *语法:wait(),该方法必须要在synchronized块中调用。 * wait执行后,线程会将持有的对象锁释放,并进入阻塞状态, *其他需要该对象锁的线程就可以继续运行了。 */ this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } //唤醒取馒头的线程 /** *语法:该方法必须要在synchronized块中调用。 *该方法会唤醒处于等待状态队列中的一个线程。 */ this.notify(); this.mt[this.index] = manTou; this.index++; } /** *取馒头 */ public synchronized ManTou pop(){ while(this.index == 0){ try { /** *语法:wait(),该方法必须要在synchronized块中调用。 * wait执行后,线程会将持有的对象锁释放,并进入阻塞状态, *其他需要该对象锁的线程就可以继续运行了。 */ this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } this.notify(); this.index--; return this.mt[this.index]; } } /** *定义生产者线程类 */ class ShengChan extends Thread{ private SyncStack ss; public ShengChan(SyncStack ss){ this.ss = ss; } @Override public void run() { for(int i=0;i<10;i++){ System.out.println("生产馒头:"+i); ManTou manTou = new ManTou(i); this.ss.push(manTou); } } } /** *定义消费者线程类 */ class XiaoFei extends Thread{ private SyncStack ss; public XiaoFei(SyncStack ss){ this.ss = ss; } @Override public void run() { for(int i=0;i<10;i++){ ManTou manTou = this.ss.pop(); System.out.println("消费馒头:"+i); } } } public class ProduceThread { public static void main(String[] args) { SyncStack ss = new SyncStack(); new ShengChan(ss).start(); new XiaoFei(ss).start(); } }
复制的和自己敲的都这样,为什么?
老师,为什么这些对象都需要手动关闭呢,为什么不会自动关闭呢
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637