📄 saver.java
字号:
package examples.threads;
/** A class to demonstrate wait and notify methods
*/
public class Saver implements Runnable {
private BankAccount account;
/** Class constructor method
* @param ba The bank account where this saver
* puts the money
*/
public Saver( BankAccount ba ) {
account = ba;
}
/** The method the saver uses to put away money */
public void run() {
while( account.isOpen() ) {
try {
if ( account.deposit( 100 ) ) {
System.out.println(
"$100 successfully deposited." );
}
Thread.currentThread().sleep( 1000 );
} catch ( InterruptedException iex ) {
// display the exception, but continue
System.err.println( iex );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -