.


:




:

































 

 

 

 


Iii .




  1. i i integer . i ii 3. i ' i i i i 1. ii i i 3 + 5 +5 = 13. i i i . i i i i .
  2. i i String . i ii "Start:". i ' i _ i i i ii. i "A", "B". ii i i "Start:ABBAAABABB". i i i . i i i i .
  3. i "ABCDEFABCDEF:". . i i i:
    • i i A i Q.
    • i i B i R.

i i i. i i i . i i i i i .

  1. i "ABCDEFABCDEF:". . i i i:
    • i i i A.
    • i i i B.

i i . i i i . i i i i .

  1. i i String . (i 0 9) i i, : "34175428457920". i i i i "A". i i i , - i i. i i i . i i i i .

 


 

6.

: ii i i i.

: i i i.

 

i ii

take() i release().

public class Semaphore { private boolean signal = false; public synchronized void take() { this.signal = true; this.notify(); } public synchronized void release() throws InterruptedException{ while(!this.signal) wait(); this.signal = false; } }

take() i i i.

release() i i , i , i i ii .

i i ii .

i take() i i i release(), , i i i i .

take() i release() i notify() i wait(), i, i i ii .

 





:


: 2016-11-24; !; : 528 |


:

:

, , . , .
==> ...

1601 - | 1439 -


© 2015-2024 lektsii.org - -

: 0.013 .