Java??????У?java.lang.Object
???????????? ???????[ 2014/5/29 13:22:02 ] ????????Java java.lang.Object
???????????hashCode()????д?г?????result*31???????result*31 = (result<<5) - result??????????31????????????????????????Ч???????????????????????????????????
????7.public String toString();
????toString()?????????????????????????????Object?е???巽???壺
????1 public String toString() {
????2 return getClass().getName() + "@" + Integer.toHexString(hashCode());
????3 }
????toString()?????????????????????????????????????????????System.out.println(obj)??????????????toString()???????
????getClass()?????????????getClassName()??String????????????????????????????Integer.toHexString(hashCode())?????????????????Σ???16???????????????????????????????????????
???????????е?u1????????638????????16?????27e??????toString()??????????????com.corn.objectsummary.User@27e??
????????toString()??????????????????????????????????????????????????toString()????????????????????
????8/9/10/11/12. wait(...) / notify() / notifyAll()
????????wait(...) / notify() | notifyAll()???????????????????????????????????????????java?????????Э????????忴??????????????????壺
????wait()?????????????????????????????????????????????????????????????notify()/notifyAll()??????
????wait(long timeout)/wait(long timeout?? int nanos)?????????????????????????????????????????????????????????????notisfy()/notisfyAll()????????????????????????
????notify()/notifyAll()?????????????????????????????/????????
????wait(...) / notify() | notifyAll()?????????????????á?????????????????????
1 package com.qqyumidi;
2
3 public class ThreadTest {
4
5 /**
6 * @param args
7 */
8 public static void main(String[] args) {
9 // TODO Auto-generated method stub
10 MyRunnable r = new MyRunnable();
11 Thread t = new Thread(r);
12 t.start();
13 synchronized (r) {
14 try {
15 System.out.println("main thread ???t????????");
16 r.wait();
17 System.out.println("??notity???????????????");
18 } catch (InterruptedException e) {
19 // TODO Auto-generated catch block
20 e.printStackTrace();
21 System.out.println("main thread ????????????????????");
22 }
23 System.out.println("???t????????" + r.getTotal());
24 }
25 }
26 }
27
28 class MyRunnable implements Runnable {
29 private int total;
30
31 @Override
32 public void run() {
33 // TODO Auto-generated method stub
34 synchronized (this) {
35 System.out.println("Thread name is:" + Thread.currentThread().getName());
36 for (int i = 0; i < 10; i++) {
37 total += i;
38 }
39 notify();
40 System.out.println("???notif???????????????????????????????");
41 }
42 System.out.println("???notif???????????????????????????????????");
43 }
44
45 public int getTotal() {
46 return total;
47 }
48 }
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11