快速,持续,稳定,傻瓜式
支持Mysql,Sqlserver数据同步

java实现同步的几种方式(总结)

请联系QQ:1793040 索取软件

复制代码
package threadTest;


public class SyncThreadTest {

    public static void main(String args[]){
        final Bank bank=new Bank();
        
        Thread tadd=new Thread(new Runnable() {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub
                while(true){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    bank.addMoney(100);
                    bank.lookMoney();
                    System.out.println("\n");
                    
                }
            }
        });
        
        Thread tsub =new Thread(new Runnable() {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub
                while(true){
                    bank.subMoney(100);
                    bank.lookMoney();
                    System.out.println("\n");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }    
                }
            }
        });
        tsub.start();
        
        tadd.start();
    }
}
复制代码

相关推荐

咨询软件
 
QQ在线咨询
售前咨询热线
QQ1793040