SCJP问题(6)-关于线程 肯定是E啦,线程由cpu随机调配,结果不能确定的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 QUESTION 61 Exhibit :1. public class SyncTest{2. public static void main(String[] args) {3. final StringBuffer s1= new StringBuffer();4. final StringBuffer s2= new StringBuffer();5. new Thread () {6. public void run() {7. synchronized(s1) {8. s2.append("A");9. synchronized(s2) {10. s2.append("B");11. System.out.print(s1);//这个没输出12. System.out.print(s2);13. }14. }15. }16. }.start();17. new Thread() {18. public void run() {19. synchronized(s2) {20. s2.append("C");21. synchronized(s1) {22. s1.append("D");23. System.out.print(s2);24. System.out.print(s1);//这个输出D25. }26. }27. }28. }.start();29. }30. }怎么都没答案,楼主是不是抄错啊? [求助]关于多线程的运行结果, 请教大牛们 抽象类概念的问题,关于类 AbstractAction swing中如何获取本机电脑名称? j2se5.0哪里有下的? java的编译器都用什么配置啊? JScrollPane 疑问? 急救!!! 在一个panel里弹出一个对话框后,在这个对话框中怎么调用该panel的某些方法? 如何响应键盘 请问?????????????? 如何启动和关闭一个进程(java写的)。 如何通过applet的权限封锁,实现读取客户硬件断口? 除了sun以外,那里下载jdk1.5比较快?
1. public class SyncTest{
2. public static void main(String[] args) {
3. final StringBuffer s1= new StringBuffer();
4. final StringBuffer s2= new StringBuffer();
5. new Thread () {
6. public void run() {
7. synchronized(s1) {
8. s2.append("A");
9. synchronized(s2) {
10. s2.append("B");
11. System.out.print(s1);//这个没输出
12. System.out.print(s2);
13. }
14. }
15. }
16. }.start();
17. new Thread() {
18. public void run() {
19. synchronized(s2) {
20. s2.append("C");
21. synchronized(s1) {
22. s1.append("D");
23. System.out.print(s2);
24. System.out.print(s1);//这个输出D
25. }
26. }
27. }
28. }.start();
29. }
30. }
怎么都没答案,楼主是不是抄错啊?