关于Myeclipse中死循环退出的问题。

有三段死循环代码
1.

public void Method()
        {
            int i = 1;

            while(i <= 9 )
            {
                int j = 1;
                while(j<=i)
                {   
                    System.out.print(i*j);
                    System.out.print("\t"); 
                    j++;
                j = 1;      //死循环
                }
                i++;
                System.out.println();       
            }
        }

2.

public void Method()
        {
            for(int j =1 ;j>0; j++)
            {
                System.out.print(j);
            }
        }

3.

public void Method()
        {
            for(int j =1 ;j>0; j++)
            {
                System.out.println(j);
            }
        }

均在MyEclipse10下运行
问题1:代码1 和代码2、3均为死循环,但为何在terminate(停止)的时候代码1 要耗费的时间非常地长。

问题2:代码2 和代码3 的区别在print还是println ,但为何代码2不显示结果,但代码三println正常?

1个回答

问题1:
第一个题单从两个while语句来说时间复杂度就是O(n2),二,三题时间复杂度是O(n)。而且,题一占用空间资源多,应该总共是10 排数字1。一直循环输出,所以说在空间复杂度上占有资源也很大,故时间长。虽然现在手段,技术用空间复杂度代替了时间复杂度。但是在一定程度上能够获得的效益却不怎么好,毕竟时间真的在消耗着。具体了解: http://wenku.baidu.com/view/190b64c59ec3d5bbfd0a7417.html
问题2:假如我们打印同一个字符(字符串),结果如下:
print()打印结果(页面):
a a a a a a a a a a aaaaaaaaaa

println()打印结果:
a
a
a
a
a
a
a
a
a
a
aaaaaaaaaa

在Java编程中,我们常常用System.out.println()方法来输出字符串,也许我们都已经猜到println()是方法名,但System是什么,out又是什么呢?

这里就涉及用到一个static关键字。其实System是java.lang里面的一个类。而out就是System里面的一个数据成员(也称为字段),但这个成员不是基本类,而是java.io.PrintStream类的对象,java.io.PrintStream类有些什么方法等一下再说。被关键字static修饰的数据成员或方法可以直接通过“类名.数据成员”或“类名.方法”来引用,而无须先建立对象。所以System.out是应用了out这个静态数据成员。而out又是一个java.io.PrintStream类的对象,所以out必然可以调用java.io.PrintStream类里面的方法,println()就是java.io.PrintStream类里的一个方法,它的作用就是用来想控制台输出信息的。String类的最大范围是;0 到2,147483,647 bytes 。超出范围就会报错。当然无法输出。但是换行就行。所以建议你不要一下子读完啊,可以用缓冲一次读取一点或者用readLine()方法,一行一行的读。就没有问题。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于 死循环如何退出
我用的时windows2000+iis环境rn在编程的时候经常出现死循环rn如果出现了机器就奇慢,关掉网页也不行,只有重启机器rnrn大家遇到过吗,都怎么解决的啊?rn
退出死循环
我写的代码里不小心加入了一个死循环,现在在调试状态下运行,我想退出死循环状态,但不希望关掉vb,因为我的代码没保存。不知该怎么做?
怎样退出死循环中的线程
我在程序中这样创建了线程rnwhile(true)rnrn Sleep(1000);rn honkHandle=CreateThread(0, 0, (LPTHREAD_START_ROUTINE) TransImg, 0, 0, &threadID);rnrn调用之后,总是无法退出程序,应该怎么做呢?
关于死循环中关闭窗口的问题
在一个while死循环中使用了Application->ProcessMessages(),窗口上的控件和最大化、最小化按钮都好用,唯独[X]按钮失灵,真郁闷。rn请教一下有没有解决的方法?(除了多线程)rn谢谢!
在视图类中如何退出死循环?????
我的program如下:rnint m_nCurFrame;//提取的文件的当前帧rnint m_nMax; //文件的总帧数rnBOOL bb;rnrnCXXView::CXXViewrnrn bb = FALSE;rnrnrnvoid CXXView::OnAutoProcessing()rnrn while (m_nCurFrame++
java退出死循环while(true)
//若是temp_msg!=null就退出while(true),超过8秒也退出 long t1 = System.currentTimeMillis(); while (true){ long t2 = System.currentTimeMillis(); if(t2-t1 &gt; 8000){ break; }else if(temp_msg!=n...
【netbeans】 netbeans如何退出死循环?
netbeans如何退出死循环?
关于有死循环子线程的应用程序的退出问题.(50分相送)
我写了一个服务端的通信程序,其中用AfxBeginThread生成了一个子线程,由这个线程来完成服务端的通讯,由于是写成了死循环while(1)其中是收到连接请求的处理,在rn退出程序时(比如:OnAppExit)时,会报一个内存错误,我知道肯定是死循环通讯线程引起的,可是怎么才能避免这个内存错误警告框呢?
关于嵌入SQL读游标时,死循环不退出的问题
有一个嵌入SQL的C++程序,在读一个游标时,不知何故陷入一不退出的死循环rn该SQL语句是个SELECT COUNT(*) FROM 语句,只会返回一条记录rnrn数据库:INFORMIX 9.3 环境:AIX 5.1rnrnrn处理过程如下:rn//先是设置锁等待rnEXEC SQL SET LOCK MODE TO WAIT 30;rnrn然后PREPARE SQLrn然后DECLARE CURSOR、OPEN CURSORrnrn然后是一个循环rnfor(;;)rnrn EXEC SQL FETCH cur_StatBillDup INTO :m_count;rnrn if (SQLCODE == 100)rn rn break;rn rn else if (SQLCODE != 0)rn rn *pSQLCODE = SQLCODE;rn DL((ALL, "ERROR: Failed to fetch data from cursor cur_StatBillDup(SQLCODE = '%d').\n", SQLCODE));rn //exit(-1);rn return -1;rn rnrnrn就在这里,经跟踪,SQLCODE总是为0,导致退不出这个FOR循环rn这段程序已经使用很久的了,一直都没有问题,今天不知道为何就出现这个鬼火来了rnrn另外,使用了一个指针指向这个SQLCODErnlong *p = &SQLCODE; // 这句是在函数的声明语句里,SQLCODE的地址作为一个默认值给了指针 p
关于正则表达式的死循环问题
我要用一个正则表达式同时匹配如下内容,正则用 VBScript_RegExp_55_TLB 或perlrnrn1、 rnrn2、 rnrn我这样写rnrn rnrn是可以取到子匹配 分别为空 和 class="xxx" ,注意,这里我是要子匹配能取到空值。rn rn但是但在某些时候测试时,会发生死循环。rnrnrn关于正则的说明有这样一段话rnrn能匹配空字符串的子匹配不要循环无限次。如果括号内的子表达式中的每一部分都可以匹配 0 次,而这个括号整体又可以匹配无限次,匹配过程中可能死循环。虽然现在有些正则表达式引擎已经通过办法避免了这种情况出现死循环了,比如 .NET 的正则表达式,但是我们仍然应该尽量避免出现这种情况。如果我们在写表达式时遇到了死循环,也可以从这一点入手。rnrnrn死循环应该与此有关,请问,要达到我的目的,该怎么写这个正则?rnrn
myeclipse无缘无故退出
我的老是无缘无故退出,rn不知道怎么回事,rn我的是9.0的rn
myeclipse异常退出
以前myeclipse还好,现在升级了内存(>4g)后,eclipse就经常异常退出。rnrn根据网上的方法,修改myeclipse.ini如下:rnrn#utf8 (do not remove)rn#utf8 (do not remove)rn-startuprn../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jarrn--launcher.libraryrn../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_3.2.0.v201103301700rn-installrnD:/Program Files/MyEclipse/MyEclipse 10rn-vmrnD:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client/jvm.dllrn-vmargsrn-Xmx512mrn-XX:MaxPermSize=512mrn-XX:ReservedCodeCacheSize=256mrn-Dosgi.nls.warnings=ignorernrn后,问题依旧,异常退出后的日志如下:rn#rn# An unexpected error has been detected by Java Runtime Environment:rn#rn# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6da2f795, pid=5540, tid=2696rn#rn# Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)rn# Problematic frame:rn# V [jvm.dll+0x17f795]rn#rn# If you would like to submit a bug report, please visit:rn# http://java.sun.com/webapps/bugreport/crash.jsprn#rnrn--------------- T H R E A D ---------------rnrnCurrent thread (0x01a29000): VMThread [stack: 0x52380000,0x52480000] [id=2696]rnrnsiginfo: ExceptionCode=0xc0000005, reading address 0x65646e71rnrnRegisters:rnEAX=0x356fd168, EBX=0x01b6f9a0, ECX=0x65646e65, EDX=0x00000000rnESP=0x5247f9b0, EBP=0x5247f9fc, ESI=0x356fd168, EDI=0x356fd168rnEIP=0x6da2f795, EFLAGS=0x00010293rnrnTop of Stack: (sp=0x5247f9b0)rn0x5247f9b0: 01b6f9a0 5247f9fc 146d0000 07628000rn0x5247f9c0: 37d70000 356fd168 004b3327 01b6f9a0rn0x5247f9d0: 00000000 37d53680 00000000 6d95f48crn0x5247f9e0: 356fd168 01b6d6d0 01b6f7f8 6d95b609rn0x5247f9f0: 5247f9fc 00000001 01b6d6d0 01b6f7f8rn0x5247fa00: 01b6f9a0 356fd200 00010100 000107d6rn0x5247fa10: 00000000 00000000 00041f58 000107d6rn0x5247fa20: 5466c100 6d95b775 00000004 01b62ae8 rnrnInstructions: (pc=0x6da2f795)rn0x6da2f785: 24 30 89 74 24 14 e9 cf 00 00 00 8b fe 8b 4f 04rn0x6da2f795: 8b 51 0c 83 c1 08 8b c2 c1 f8 02 85 d2 89 54 24 rnrnrnStack: [0x52380000,0x52480000], sp=0x5247f9b0, free space=1022krnNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)rnV [jvm.dll+0x17f795]rnrnVM_Operation (0x6378fa14): GenCollectFull, mode: safepoint, requested by thread 0x53a67000rnrnrn--------------- P R O C E S S ---------------rnrnJava Threads: ( => current thread )rn 0x53a67000 JavaThread "Thread-15" [_thread_blocked, id=3744, stack(0x63690000,0x63790000)]rn 0x56bbd400 JavaThread "org.eclipse.jdt.internal.ui.text.JavaReconciler" daemon [_thread_blocked, id=6132, stack(0x5a8d0000,0x5a9d0000)]rn 0x54253000 JavaThread "[ThreadPool Manager] - Idle Thread" daemon [_thread_blocked, id=1184, stack(0x5a6d0000,0x5a7d0000)]rn 0x54253400 JavaThread "com.google.inject.internal.util.$Finalizer" daemon [_thread_blocked, id=6060, stack(0x59600000,0x59700000)]rn 0x54251800 JavaThread "JavaScript indexing" daemon [_thread_blocked, id=6048, stack(0x59500000,0x59600000)]rn 0x56bc0400 JavaThread "DLTK indexing" daemon [_thread_blocked, id=3684, stack(0x55320000,0x55420000)]rn 0x56bbfc00 JavaThread "MultiThreadedHttpConnectionManager cleanup" daemon [_thread_blocked, id=2668, stack(0x55220000,0x55320000)]rn 0x56bbf800 JavaThread "MyEclipse Thread" [_thread_blocked, id=5852, stack(0x55120000,0x55220000)]rn 0x56bbdc00 JavaThread "com.jniwrapper.NativeResourceCollector" daemon [_thread_blocked, id=5908, stack(0x59400000,0x59500000)]rn 0x56bbe000 JavaThread "Worker-17" [_thread_blocked, id=4644, stack(0x59300000,0x59400000)]rn 0x53a6c400 JavaThread "Worker-16" [_thread_blocked, id=4368, stack(0x59200000,0x59300000)]rn 0x53a6b800 JavaThread "Worker-15" [_thread_blocked, id=4360, stack(0x59100000,0x59200000)]rn 0x53a6b400 JavaThread "Worker-14" [_thread_blocked, id=4356, stack(0x59000000,0x59100000)]rn 0x53a6b000 JavaThread "Worker-13" [_thread_blocked, id=5688, stack(0x58f00000,0x59000000)]rn 0x53a6a800 JavaThread "Worker-12" [_thread_blocked, id=3516, stack(0x58e00000,0x58f00000)]rn 0x53a6a400 JavaThread "Worker-11" [_thread_blocked, id=2732, stack(0x58d00000,0x58e00000)]rn 0x53a69c00 JavaThread "Worker-10" [_thread_blocked, id=5324, stack(0x58250000,0x58350000)]rn 0x53a69000 JavaThread "Worker-9" [_thread_blocked, id=5512, stack(0x57f50000,0x58050000)]rn 0x53a68c00 JavaThread "Worker-8" [_thread_blocked, id=5796, stack(0x57e50000,0x57f50000)]rn 0x53a68000 JavaThread "Worker-7" [_thread_blocked, id=5656, stack(0x57d50000,0x57e50000)]rn 0x53a67400 JavaThread "Worker-6" [_thread_blocked, id=4688, stack(0x57c50000,0x57d50000)]rn 0x53a67c00 JavaThread "Worker-5" [_thread_blocked, id=5848, stack(0x57b50000,0x57c50000)]rn 0x53a65c00 JavaThread "Worker-4" [_thread_blocked, id=5588, stack(0x57a50000,0x57b50000)]rn 0x53a64c00 JavaThread "Worker-3" [_thread_blocked, id=3912, stack(0x54b00000,0x54c00000)]rn 0x53a66400 JavaThread "Java indexing" daemon [_thread_blocked, id=5008, stack(0x56140000,0x56240000)]rn 0x53a65800 JavaThread "Bundle File Closer" daemon [_thread_blocked, id=5300, stack(0x548f0000,0x549f0000)]rn 0x53a65000 JavaThread "Worker-2" [_thread_blocked, id=6072, stack(0x54ca0000,0x54da0000)]rn 0x5435a400 JavaThread "Worker-1" [_thread_blocked, id=3800, stack(0x547f0000,0x548f0000)]rn 0x54359c00 JavaThread "Worker-0" [_thread_blocked, id=3984, stack(0x53e00000,0x53f00000)]rn 0x5374e000 JavaThread "Worker-JM" [_thread_blocked, id=4956, stack(0x53d00000,0x53e00000)]rn 0x53718800 JavaThread "[Timer] - Main Queue Handler" daemon [_thread_blocked, id=4408, stack(0x53c00000,0x53d00000)]rn 0x52c0b400 JavaThread "Framework Event Dispatcher" daemon [_thread_blocked, id=496, stack(0x53600000,0x53700000)]rn 0x52cd8400 JavaThread "Start Level Event Dispatcher" daemon [_thread_blocked, id=2840, stack(0x53500000,0x53600000)]rn 0x52cbe400 JavaThread "State Data Manager" daemon [_thread_blocked, id=5888, stack(0x53400000,0x53500000)]rn 0x52cc3000 JavaThread "Framework Active Thread" [_thread_blocked, id=5752, stack(0x53250000,0x53350000)]rn 0x01a7b000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5288, stack(0x52980000,0x52a80000)]rn 0x01a79c00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=5728, stack(0x52880000,0x52980000)]rn 0x01a73400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5808, stack(0x52780000,0x52880000)]rn 0x01a68c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=5732, stack(0x52680000,0x52780000)]rn 0x01a31000 JavaThread "Finalizer" daemon [_thread_blocked, id=5840, stack(0x52580000,0x52680000)]rn 0x01a2c400 JavaThread "Reference Handler" daemon [_thread_blocked, id=3900, stack(0x52480000,0x52580000)]rn 0x01b69400 JavaThread "main" [_thread_blocked, id=5760, stack(0x00030000,0x00130000)]rnrnOther Threads:rn=>0x01a29000 VMThread [stack: 0x52380000,0x52480000] [id=2696]rn 0x01a7b800 WatcherThread [stack: 0x52a80000,0x52b80000] [id=5864]rnrnVM state:at safepoint (normal execution)rnrnVM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])rn[0x01b67950] UNKNOWN - owner thread: 0x01a29000rn[0x01b67db0] UNKNOWN - owner thread: 0x53a67000rnrnHeaprn def new generation total 10944K, used 8284K [0x11f70000, 0x12b50000, 0x146d0000)rn eden space 9728K, 72% used [0x11f70000, 0x12657098, 0x128f0000)rn from space 1216K, 100% used [0x12a20000, 0x12b50000, 0x12b50000)rn to space 1216K, 0% used [0x128f0000, 0x128f0000, 0x12a20000)rn tenured generation total 144248K, used 88106K [0x146d0000, 0x1d3ae000, 0x31f70000)rn the space 144248K, 61% used [0x146d0000, 0x19cda940, 0x19e44800, 0x1d3ae000)rn compacting perm gen total 96256K, used 96141K [0x31f70000, 0x37d70000, 0x51f70000)rn the space 96256K, 99% used [0x31f70000, 0x37d53680, 0x356fd200, 0x37d70000)rnNo shared spaces configured.rnrnrnVM Arguments:rnjvm_args: -Xmx512m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=256m -Dosgi.nls.warnings=ignore rnjava_command: rnLauncher Type: genericrnrnEnvironment Variables:rnPATH=D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Program Files/MyEclipse/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/i386;C:\Program Files\Ruby\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\SlickEditV16.0.2\win\;D:\Program Files\Android\android-sdk\tools;D:\QtSDK\Desktop\Qt\4.8.1\msvc2010\binrnUSERNAME=hewurnOS=Windows_NTrnPROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntelrnrnrnrn--------------- S Y S T E M ---------------rnrnOS: Windows NT 6.1 Build 7601 Service Pack 1rnrnCPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 7 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3rnrnMemory: 4k page, physical 2097151k(2097151k free), swap 4194303k(4194303k free)rnrnvm_info: Java HotSpot(TM) Client VM (11.3-b02) for windows-x86 JRE (1.6.0_13-b03), built on Mar 9 2009 01:15:24 by "java_re" with MS VC++ 7.1rnrntime: Tue Sep 11 09:01:28 2012rnelapsed time: 76 secondsrnrn[color=#FF0000]从日志上看,发生问题出在[jvm.dll+0x17f795]这里,[/color],这个问题已经困扰好几天了,还望高手指点。rnrnp.s.:限于篇幅,略去Dynamic Libraries部分
MyEclipse 6.5异常退出
为什么我的MyEclipse经常异常退出呢?rn详见图片rn[img=http://gtfe8g.blu.livefilestore.com/y1pQ0XTKr-ayO7S4cAKoJslE6nTmzgJzlKolNDtlegkrpzY6BV6UjvZJftK1wcmdJJMBzz4aBygPgb19w0FtV8-5A/err.bmp][/img]
在嵌套循环中的死循环问题
[code=c]rnrn#includernint main()rnrnrn int j=10;rn int k=10;rn while(j--)rn rnrn while(k--)rn rn printf("%d",k);rnrn rnrn rnrnrn//这样会 输出一堆负数是为什么?rn// 如果把k--挪到循环体内,把条件改为k>0 就恢复正常了rnrnrn printf("over");rn return 0;rnrnrn[/code]
myeclipse自动退出
用myeclipse写Java程序的时候只要写request.getParameter()语句, 并且还没有写完就要自动关闭,解决办法   ... 在项目上点右键——Build Path——config build path——右边的Libraries下面的每个jar包展开 ,选中javadoc location,如果javadoc location后面是一个网址的话就点击右侧的Remo...
java中的死循环问题。
大家一般用什么方法跳出死循环的?最好举个简单的例子。。
关于死循环..
我最近要做个发短信的服务,用wcf做的.问题是 移动提供的服务 不能高并发 每秒只能6个rn我这边现在的想法是用队列,页面请求的 加入队列rnrn现在比较菜的问题是 我怎么触发 发送队列的msgrn是一直死循环check这个队列吗? rn有什么好的想法?rn求指导,本人小菜
MYEclipse 中关于乱码的问题
window--&amp;gt;persion --&amp;gt;General--&amp;gt;content Types--&amp;gt;Text --&amp;gt;Jsp --&amp;gt;UTF-8
关于myeclipse中路径的问题!
我建立了一个web project 里面写了一个XML读取的类,对于java webproject 里面使用我这个类的时候需要传入读取xml 的路径。我是java 新手。。。对于xml 的相对路径不熟悉。。。。rn在java web project 里面根目录是相对那个目录??是工程的根目录吗?还是webroot文件夹这个目录?或者还是别的??
关于在MYECLIPSE中中文输入的问题
在页面代码中 当输入中文的时候,系统就提示你rn:the encoding(ISO-8859-1)cannot convert some characters。。。。。。rn怎么办啊!!!
关于Weblogic在Myeclipse中的问题
各位大虾!今天刚接触Weblogic这个服务器,安装配置好后,在Myeclipse中配置后启动出现以下问题:rn <2008-7-30 上午09时41分52秒 CST> rn<2008-7-30 上午09时41分52秒 CST> rn<2008-7-30 上午09时41分52秒 CST> rnrnrn请各位大虾帮忙!
myeclipse 启动中退出,log文件如下:
!SESSION 2011-09-04 11:27:11.785 -----------------------------------------------rneclipse.buildId=unknownrnjava.version=1.6.0_13rnjava.vendor=Sun Microsystems Inc.rnBootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CNrnCommand-line arguments: -os win32 -ws win32 -arch x86rnrn!ENTRY org.eclipse.osgi 2 1 2011-09-04 11:27:30.687rn!MESSAGE NLS unused message: prompt_optclasspath in: com.genuitec.eclipse.easie.core.configurationrnrn!ENTRY org.eclipse.osgi 2 1 2011-09-04 11:27:30.688rn!MESSAGE NLS unused message: prompt_preclasspath in: com.genuitec.eclipse.easie.core.configurationrnrn!ENTRY org.eclipse.osgi 2 1 2011-09-04 11:27:30.689rn!MESSAGE NLS unused message: prompt_optlibrarypath in: com.genuitec.eclipse.easie.core.configurationrnrn!ENTRY org.eclipse.jface 2 0 2011-09-04 11:27:32.724rn!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.rn!SUBENTRY 1 org.eclipse.jface 2 0 2011-09-04 11:27:32.724rn!MESSAGE A conflict occurred for SHIFT+DEL:rnBinding(SHIFT+DEL,rn ParameterizedCommand(Command(org.eclipse.datatools.sqltools.result.removeAllInstances,Remove All Visible Results,rn ,rn Category(org.eclipse.datatools.sqltools.result.category,SQL Results View,null,true),rn ,rn ,,true),null),rn org.eclipse.ui.defaultAcceleratorConfiguration,rn org.eclipse.ui.contexts.window,,,system)rnBinding(SHIFT+DEL,rn ParameterizedCommand(Command(org.eclipse.ui.edit.cut,Cut,rn Cut the selection to the clipboard,rn Category(org.eclipse.ui.category.edit,Edit,null,true),rn org.eclipse.ui.internal.handlers.WidgetMethodHandler@f6178d,rn ,,true),null),rn org.eclipse.ui.defaultAcceleratorConfiguration,rn org.eclipse.ui.contexts.dialogAndWindow,,,system)rnBinding(SHIFT+DEL,rn ParameterizedCommand(Command(org.topcased.modeler.deleteModelObject,Delete From Model,rn Allows the user to delete the selected graph element and its associated model element in a Topcased editor.,rn Category(org.eclipse.ui.category.edit,Edit,null,true),rn ,rn ,,true),null),rn org.eclipse.ui.defaultAcceleratorConfiguration,rn org.eclipse.ui.contexts.window,,,system)rnrn!ENTRY org.eclipse.ui.workbench 2 0 2011-09-04 11:27:33.914rn!MESSAGE A handler conflict occurred. This may disable some commands.rn!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2011-09-04 11:27:33.914rn!MESSAGE Conflict for 'com.genuitec.eclipse.ast.deploy.core.runonservershortcut.debug':rnHandlerActivation(commandId=com.genuitec.eclipse.ast.deploy.core.runonservershortcut.debug,rn handler=org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension$LaunchCommandHandler@1c96492,rn expression=,sourcePriority=0)rnHandlerActivation(commandId=com.genuitec.eclipse.ast.deploy.core.runonservershortcut.debug,rn handler=org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension$LaunchCommandHandler@63ed4,rn expression=,sourcePriority=0)rn
关于网络编程多线程死循环问题
关于网络编程多线程死循环问题,我写一个聊天服务器程序,基于TCP的,rn WSADATA wsaData;rn if( WSAStartup(MAKEWORD(2,2),&wsaData)!=0)//初始化WSA 调用成功则返回0rn rn MessageBox(NULL,"初始化失败","",MB_OK);rn WSACleanup();rn rnrn SOCKET ServerSock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); //SOCK_STREAM 流式套接字rn //IPPROTO_TCP TCP协议 用于流式套接字rn if(INVALID_SOCKET ==ServerSock)rn rn MessageBox(NULL,TEXT("创建套接字失败"),"",MB_OK);rn WSACleanup();rn rn rnrn sockaddr_in server;rn server.sin_addr.S_un.S_addr = INADDR_ANY; //本机iprn server.sin_family = AF_INET ; //指定通信协议rn BOOL Err;rn UINT Port =GetDlgItemInt(hwnd,IDC_PORT,&Err,TRUE); rn server.sin_port = htons(Port); //主机字节顺序转成网络字节顺序rn if(bind(ServerSock,(LPSOCKADDR)&server,sizeof(server))==SOCKET_ERROR)rn rn MessageBox(NULL,TEXT("绑定套接字失败"),"",MB_OK);rn closesocket(ServerSock);rn rnrn if(listen(ServerSock,5)==SOCKET_ERROR)rn rn MessageBox(NULL,TEXT("监听失败"),"",MB_OK);rn closesocket(ServerSock);rn rn rn SetDlgItemText(hwnd,IDC_SYSTEMMSG,TEXT("服务器正在监听.....")); rnrn rn SOCKET TcpSocket;rn SOCKADDR_IN TcpClientAddr;rn while(1)rn rn int alen;rn TcpSocket=accept(ServerSock,(SOCKADDR*)&TcpClientAddr,&alen);rn if(TcpSocket<0)rn rn exit(1);rn rn ........rn rn在上面的循环中为什么会出现死循环呢 我在这个循环中用accept不断接收连接请求,到底哪错了啊
关于while()一个死循环问题
while(i!=0&&i==-i)rnrn如何申明i可以使这个while成为死循环rnrn还有个小问题System.out.println(2.00-1.10)rn为什么打印出的是0.8999999999999999
关于Makefile编译时死循环问题
2 ifneq ($(EXE),"")n 33 all:$(EXE)n 34 endifn 35 n 36 ifneq ($(LIBS),"")n 37 all:$(LIBS)n 38 endifn 39 n 40 ifneq ($(MAKECMDGOALS),clean)n 41 -include $(DEPS)n 42 endif-n 43 $(DIRS):n 44 | $(MKDIR) $@n 45 n 46 $(EXE):$(DIR_EXES) $(OBJS)n 47 | $(CC) $(filter %.o, $^) -o $@n 48 $(LIBS):$(DIR_LIBS) $(OBJS)n 49 | $(AR) $(ARFLAGS) $@ $(filter %.o,$^)-n 50 $(DIR_OBJS)/%.o:$(DIR_OBJS) %.cn 51 | $(CC) -c $(filter %.c, $^) -o $@n 52 $(DIR_DEPS)/%.d:$(DIR_DEPS) %.cn 53 | @set -e;\n 54 | echo "Making $@...";\n 55 | $(RM) $(RMFLAGS) $@;\n 56 | $(CC) -E -MM $(filter %.c, $^) > $@.tmp;\n 57 | sed 's,\(.*\).o[ :],objs/\1.o $@ :,g' < $@.tmp > $@;\n 58 | $(RM) $(RMFLAGS) $@.tmp;-n为什么进行头文件依赖的时候如果不在58行后边添加mv $@ $@的话其会一直循环执行 如果其模式匹配直接为%.d:%.c的话其执行没有问题nn[root@localhost src]# makenmkdir depsnMaking deps/foo.d...nMaking deps/foo.d...nMaking deps/foo.d...nMaking deps/foo.d...n这位其执行结果
求助。关于死循环与字符类型的问题
while(true)rnrn int i;rn cin>>i;rn rn switch(i)rn rn case 1:排序..;break;rn case 2:输出..;break;rn case 3:插入..;break;rn case 4:删除..;break;rn case 0:退出程序;exit(0);rn default:提示错误; rn rnrn输入整数i的 时候,程序都能按预定情况运行。。rn但是输入字母或者带小数点的数时 就会死循环,;rn求一个比较简洁的判断i的方法。。。
myeclipse 启动退出,好像是工作空间的问题
之前好好的, 今天运行myeclipse 启动画面到一半,myeclipse就无声无息地消失了,没有弹出任何报错框。rnrn在myeclipse的安装目录下,找到以下日志,太长,我传到了这里:http://derline.mysinamail.com/hs_err_pid4056.logrnrn请有耐心的朋友阅览一下!指点一下,谢谢了!
线程死循环,如何退出该线程
小弟想执行的功能是当程序处于该界面的时候创建一个线程,在该线程中一直不停的循环检测某个感应器状态,程序切换界面后该线程退出。线程中执行的是死循环,不知道该如何退出,小弟刚接触多线程,还请各位大神解惑。
getchar()在死循环中出现的问题
为什么完成一次循环后,屏幕会出现两行“Do you want to build a new node?”rnrnrn[code=C/C++]int main()rnrn char c;rn for(; ;)rnrnprintf("Do you want to build a new node?\n");rn c = getchar();rn if(c == 'n')rn break;rn if(c != 'y' && c != 'n')rn continue;rn if(c == 'y')rn printf("hello world\n");rn rn[/code]
死循环问题
这是 cpp文件的主要的一部分,我想每次输完一个数,例如1,执行完程序后会再显示除了标题 “各 种 排 序 算 法 效 率 分 析”外的剩下的那些排序名称,我便可再选择一个数,如2,再执行……按0会停止。但这个程序并不可以这样,而是选了1 后choice就一直是1了,一直循环下去,不再scanf了。为什么?有谁有解决办法吗?谢谢。rnrnvoid main()rn //char ch;rn int choice;rn printf("-------------------------------------------------------\n");rn printf("| |\n");rn printf("| 各 种 排 序 算 法 效 率 分 析 |\n");rn printf("| |\n");rn printf("|-----------------------------------------------------|\n");rn printf("|-----------------------------------------------------|\n");rn printf("| 1.直接插入排序 |\n");rn printf("| 2.折半插入排序 |\n");rn printf("| 3.希尔排序 |\n");rn printf("| 4.冒泡排序 |\n");rn printf("| 5.快速排序 |\n");rn printf("| 6.简单选择排序 |\n");rn printf("| 7.堆排序 |\n");rn printf("| 8.非递归归并排序 |\n");rn printf("| 9.基数排序 |\n");rn printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");rn printf("| 0.Exit System |\n");rn printf("|-----------------------------------------------------|\n");rn printf("# Please Input Your Choose #\n");rn printf("|-----------------------------------------------------|\n");rnrnrnscanf("%d",&choice);rnrn//while(scanf("%d",&num)!=EOF&&num!=0)rn while(choice!=0)rn rn rn //cin>>choice;rn //scanf("%d",&choice);rn //getchar();rn switch(choice)rn rn case 1: main1() ;break;rn case 2: main2() ;break;rn case 3: main3() ;break;rn case 4: main4() ;break;rn case 5: main5() ;break;rn case 6: main6() ;break;rn case 7: main7() ;break;rn case 8: main8() ;break; rn case 9: main9() ;break;rnrn //case '0': exit(0);rn rn default: break;rn rn printf("|-----------------------------------------------------|\n");rn printf("| 1.直接插入排序 |\n");rn printf("| 2.折半插入排序 |\n");rn printf("| 3.希尔排序 |\n");rn printf("| 4.冒泡排序 |\n");rn printf("| 5.快速排序 |\n");rn printf("| 6.简单选择排序 |\n");rn printf("| 7.堆排序 |\n");rn printf("| 8.非递归归并排序 |\n");rn printf("| 9.基数排序 |\n");rn printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");rn printf("| 0.Exit System |\n");rn printf("|-----------------------------------------------------|\n");rn printf("# Please Input Your Choose #\n");rn printf("|-----------------------------------------------------|\n");rnscanf("%d",&choice);rnrn rnrnrnrn
关于退出问题?
class MyListener implements ActionListenerrn rn public void actionPerformed(ActionEvent ae)rn rn ......rn if(ab.getText().equals("确定"))rn rn ////////查好友//////////////////rn if(panel_2.button_zhijie.isSelected())rn rn System.out.println ("ds") ;rn String QQnumber = panel_2.tf_QQ.getText() ;rn String nicheng = panel_2.tf_nicheng.getText() ;rn ///连服务器///////////rn if(testPerform(QQnumber))rn rn System.out.println (QQnumber) ;rn QQ.setName(nicheng) ;rn QQ.setQQ_number(QQnumber) ;rn QQ.setHead("查找好友") ;rn tryrn rn new ClientSocket(LR_QQ_pane.server,LR_QQ_pane.serverport,QQ) ; rn rn catch(Exception e)rn rn JOptionPane.showMessageDialog(Find.this,"服务器忙") ; rn rn rn rn ///////////////////查在线QQ//////////rn if(panel_2.button_zaixian.isSelected())rn rn QQ.setHead("在线查找") ;rn tryrn rn new ClientSocket(LR_QQ_pane.server,LR_QQ_pane.serverport,QQ) ; rn rn catch(Exception e)rn rn JOptionPane.showMessageDialog(Find.this,"服务器忙") ; rn rn rn panel_2.tf_QQ.setText("") ;rn panel_2.tf_nicheng.setText("") ;rn rn rn// if(ab.getText().equals("取消"))rn// rn// //注销当前窗口rn// System.exit(0);rn// rn rn rnrn在取消按钮里面写什么进去,能让窗体消失而程序不结束嘛?
关于多文档退出的问题.
有一个MDIform,和form2,在MDIform中的菜单调用了form2,使form2显示(form2.show)rn在操作mdiform时,form2会隐藏到mdiform后面.我不需要把form2设置成模式显示.rn当我退出mdiform时也就是点击mdiform右上角的退出按钮时要判断rnif form2.visuable=true thenrn form2.showrnelse rn 退出程序.rnendifrn但是问题是,form2显示出来了,mdiform却退出了请问怎么解决?rn我想要的是,如果form2未被退出,则程序不退.如果form2已经退了,则可以退出系统.
关于线程退出的问题
线程退出后死锁rnrn我先把相关代码帖出来,问题描述在后面rnrnvoid CMulThreadDialog::OnOK()rnrn    ......rn    m_pCmdThread = AfxBeginThread(CmdTdFunction, (LPVOID)this);rnrnrnUINT __cdecl CMulThreadDialog::CmdTdFunction( LPVOID pParam )rnrn CMulThreadDialog * pDlg = (CMulThreadDialog *)pParam;rn pDlg->DoCommand();rn PostMessage(WM_COMMAND, UM_ENDDIALOG, 0);rn WriteLog(1000,1000,_T("the hthread: 0x%x run end"), pDlg->m_pCmdThread->m_hThread);rn return 0; rnrnrnvoid CMulThreadDialog::OnEndDialog()rnrn MSG msg;rn while(PeekMessage(&msg, this->m_hWnd,UM_SETPROGPOS,UM_SETPROGPOS,PM_REMOVE ));rn while(PeekMessage(&msg, this->m_hWnd,UM_ENABLEUI,UM_ENABLEUI,PM_REMOVE ));rn WriteLog(1000, 1000, _T("In OnEndDialog ...\tm_pCmdThread: 0x%x, HTHREAD: 0x%x"), m_pCmdThread, m_pCmdThread->m_hThread);rn if (m_pCmdThread && m_pCmdThread->m_hThread)rn rn WaitForSingleObject(m_pCmdThread->m_hThread, INFINITE); [color=#FF0000]//1,偶尔会死在此处[/color]rn rn VisLogLine(1000, 1000, _T("OnEndDialog End"));rn CDialog::OnOK();  [color=#FF0000]//2,偶尔会死在此处[/color]                           rnrnrn问题是为什么我的线程函数已经走到return 0;了,但是我在OnEndDialog函数里输出的log中可以看到m_pCmdThread->m_hThread这个值偶尔是个有效的线程句柄值. 当这个值是个无效值时也就是说线程return后被autodelete掉了,所以handle变为无效(0xcdcdcdcd)程序可以正常退出,但有时这个值仍有效, 这时return 0也走了,线程有时会死在1处,偶尔还会死在CDialog::OnOK();里,很迷惑..
关于登录退出的问题
用户在一台机器上登录后 ,在其他地方再登陆的话 这边的机器上就退出 是怎么弄的
关于线程退出的问题!
一个注册windows系统服务的小程序,realservice代码如下:rnint RealService(char *cmd, int bInteract)rnrn HANDLE m_ServiceExitEvent = CreateEvent(NULL,TRUE,FALSE,"HelloWorld");rn if(m_ServiceExitEvent == NULL || GetLastError() rn == ERROR_ALREADY_EXISTS) rn return FALSE; rn rn //启动相应工作线程序rn UINT m_Id = 0;rn _beginthreadex(NULL , 0 , rn PlayWork , (LPVOID) NULL , 0 , &m_Id); //(LPVOID) thisrn Sleep(2000);rn return 1;rnrnUINT WINAPI PlayWork(LPVOID lPvoid)rnrn m_Exit = CreateEvent(NULL,TRUE,FALSE,NULL);rn //启动相应工作线程序rn UINT m_Id = 0;rn HANDLE m_Thread = (HANDLE) _beginthreadex(NULL , 0 , rn Main_Work, NULL , 0 , &m_Id);rn rn WaitForSingleObject(m_Exit,INFINITE); rn return 0;rnrn服务加载时,程序正常运行。卸载服务时,我在UninstallService中置线程事件为有信号rnint UninstallService(char *name)rnrn SetEvent(m_Exit);rn Sleep(5000);rn //卸载服务其他操作;rnrn但是程序显示服务卸载成功后,Main_Work线程始终没有退出。rn请问这是为什么呢?我哪里弄错了,请各位指点!
关于一个退出的问题。。。。。
具体点说:主窗口点击某菜单,然后会多次调用自己编写的同同一个dll文件,dll文件中有错误提示,我想实现如果dll中提示错误,那么整个菜单响应函数就退出。也就是出现错误,不继续进行菜单的响应,否则继续调用dll都会出现相同的错误提示.....我想直接退到主窗口,不关闭整个程序的功能。
关于门户退出问题
我有一个门户,接入了很多系统,如何能够实现退出门户后,其他接入的系统一样能够退出?
关于服务程序的退出问题。
我写了一个带界面的服务程序,rn如果服务启动以后 只能通过命令行 输入 net stop 服务来关闭。在电脑关机的时候如果这个服务没有关闭的话。关不了机。rn所以想问一下这个是什么原因?例外怎么通过服务界面上按钮点击退出服务?rn
关于APP退出的问题
这里说的“退出”指杀进程,不是在APP窗口里点退出按钮。rn请问:rn1、按我的理解,这时应该会调用 onDestroy。我就重载了一个空的 onDestroy,然并卵,照样关闭!rn2、我想知道退出时究竟有没有执行到这个函数,又加了个 Toast,还是什么都没看到。rnrn其实我想要的是这样的效果:rn退出时能弹出个对话框让用户确认,或者写个记录保存退出时间。现在担心臣妾做不到啊!rnrn代码;rn @Overridern protected void onDestroy() rn Toast.makeText(getApplicationContext(), "onDestroy", Toast.LENGTH_LONG).show();rn //注释 super.onDestroy(); rn rnrn
关于CStatusBarCtrl的退出问题
我的程序有时出现这种情况:程序主体安全退出了,可是屏幕底下的状态栏无法退出。请问各位大侠该如何解决这种问题?
相关热词 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法