Thread.currentThrread().sleep(10) or Thread.sleep(10) ?

what's the difference between the 2 calls to sleep() ?
thanks.

They call the same method (because sleep is static) even if you call sleep on a different thread the current thread executing the code will sleep

Similar Messages

  • Using wait or sleep without a thread

    Is there any method to do the equivalent of a wait or sleep without using threads?

    You have a single-threaded application executing, and
    you want to pause it at a given location for a given
    period of time. If you call sleep, you give up
    execution, which you don't want to do.What do you mean by not wanting to give "up execution"? It is the scheduler of your OS that decides when your program executes or not. Your code snippet does nothing but burn processor time (incidently pretending to the scheduler that it actually has something useful to do) which could be well used by some other process running on the computer. Use Thread.sleep instead, thats what it is there for. If you want to somehow affect the amount of processor time that the scheduler allocates to your process you will be better served by increasing its priority.
    having my skill and/or intelligence mocked Well, I have certainly not mocked your skill nor your intelligence, god knows that I have on occasion presented poor solutions in this and other forums, but lets not dwell on that...

  • Multiple threads generated on jms processing - thread locked?

    Hi,
    One of the applications we use is deployed on Oracle App Server 10g. The server runs fine until a certain time when the application receives around 50 JMS messages at the time, the server starts to slow down and becomes inoperable and only a restart fixes this. Here's the thread dump which looks like there are quite a few threads being spawned all waiting on some process. Is there any way we could figure out what is causing this slow down from this thread dump. There seems to be some thread that is locked that is causing all the other threads to wait.
    "SystemThreadGroup-88" prio=10 tid=0x00002aab45154000 nid=0x4422 in Object.wait() [0x0000000049193000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaaed94e028> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:376)
         - locked <0x00002aaaed94e028> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:787)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:266)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:42)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:302)
         at java.lang.Thread.run(Thread.java:619)
    "MetricCollector:METRICCOLL50:5" daemon prio=10 tid=0x00002aab48bd8000 nid=0x4156 in Object.wait() [0x0000000048f91000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaad5432e30> (a oracle.sysman.emSDK.emd.rt.MetricCollectorThread)
         at oracle.sysman.emSDK.emd.rt.MetricCollectorThread.run(MetricCollectorThread.java:351)
         - locked <0x00002aaad5432e30> (a oracle.sysman.emSDK.emd.rt.MetricCollectorThread)
         at java.lang.Thread.run(Thread.java:619)
    "RMICallHandler-50" prio=10 tid=0x0000000045c56800 nid=0x36a8 in Object.wait() [0x0000000049092000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aab2f89a6b0> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:376)
         - locked <0x00002aab2f89a6b0> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:787)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:266)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:42)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:302)
         at java.lang.Thread.run(Thread.java:619)
    "RMICallHandler-49" prio=10 tid=0x0000000046064000 nid=0x7fc1 in Object.wait() [0x0000000048e90000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aab2038edb0> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:376)
         - locked <0x00002aab2038edb0> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:787)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:266)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:42)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:302)
         at java.lang.Thread.run(Thread.java:619)
    "JMSRequestHandler[311:AppServ2.compass.ontario.ca:34199]" prio=10 tid=0x0000000045a50000 nid=0x5f8e runnable [0x0000000048385000]
    java.lang.Thread.State: RUNNABLE
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
         - locked <0x00002aaac7177a70> (a java.io.BufferedInputStream)
         at java.io.DataInputStream.readInt(DataInputStream.java:370)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.processRequest(TCPHandler.java:555)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.process(TCPHandler.java:521)
         at com.evermind.server.jms.TCPHandler.run(TCPHandler.java:204)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)
    "JMSRequestHandler[310:AppServ2.compass.ontario.ca:23953]" prio=10 tid=0x00000000454dd800 nid=0x4953 runnable [0x0000000048183000]
    java.lang.Thread.State: RUNNABLE
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
         - locked <0x00002aaac7177d78> (a java.io.BufferedInputStream)
         at java.io.DataInputStream.readInt(DataInputStream.java:370)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.processRequest(TCPHandler.java:555)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.process(TCPHandler.java:521)
         at com.evermind.server.jms.TCPHandler.run(TCPHandler.java:204)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)
    "OracleTimeoutPollingThread" daemon prio=10 tid=0x00002aab440b9800 nid=0x44ff waiting on condition [0x0000000048284000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
         at java.lang.Thread.sleep(Native Method)
         at oracle.jdbc.driver.OracleTimeoutPollingThread.run(OracleTimeoutPollingThread.java:157)
    "RMICallHandler-35" prio=10 tid=0x00002aab4411e000 nid=0x4379 in Object.wait() [0x0000000048082000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aab2f93af88> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:376)
         - locked <0x00002aab2f93af88> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:787)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:266)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:42)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:302)
         at java.lang.Thread.run(Thread.java:619)
    "RMIConnectionThread" prio=10 tid=0x0000000045487800 nid=0x2c64 runnable [0x0000000047b7d000]
    java.lang.Thread.State: RUNNABLE
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
         - locked <0x00002aaac717afd8> (a java.io.BufferedInputStream)
         at com.evermind.io.IOUtils.readCompressedInt(IOUtils.java:313)
         at oracle.oc4j.rmi.RmiTransport$DiscreteMessageIn.<init>(RmiTransport.java:241)
         at oracle.oc4j.rmi.RmiTransport.createDiscreteMessageIn(RmiTransport.java:232)
         at com.evermind.server.rmi.RMIProtocol$Version_1_3.getMessageIn(RMIProtocol.java:540)
         at com.evermind.server.rmi.RMIProtocol.getMessageIn(RMIProtocol.java:172)
         at com.evermind.server.rmi.RMIServerConnection.receiveInputMessage(RMIServerConnection.java:385)
         at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands(RMIConnection.java:127)
         at com.evermind.server.rmi.RMIServerConnection.listenForOrmiCommands(RMIServerConnection.java:390)
         at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:107)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)
    "TimerThread300000" daemon prio=10 tid=0x00002aab483a9800 nid=0x2c03 in Object.wait() [0x0000000047a7c000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaac52b3510> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer._doSleep(Unknown Source)
         - locked <0x00002aaac52b3510> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)
    "oracle.dms.aggregator.Timer@15000" daemon prio=10 tid=0x00002aab483a8000 nid=0x2bfa in Object.wait() [0x000000004797b000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaac56ade18> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer._doSleep(Unknown Source)
         - locked <0x00002aaac56ade18> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)
    "oracle.dms.aggregator.Timer@300000" daemon prio=10 tid=0x00002aab4883c000 nid=0x2bf9 in Object.wait() [0x000000004762c000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaac56ecf90> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer._doSleep(Unknown Source)
         - locked <0x00002aaac56ecf90> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)
    "oracle.dms.aggregator.Timer@30000" daemon prio=10 tid=0x00002aab4883b000 nid=0x2bf7 in Object.wait() [0x000000004752b000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaac56ae408> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer._doSleep(Unknown Source)
         - locked <0x00002aaac56ae408> (a oracle.dms.aggregator.Timer)
         at oracle.dms.aggregator.Timer.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
         - locked <0x00002aaabe661a78> (a java.io.BufferedInputStream)
         at java.io.DataInputStream.readInt(DataInputStream.java:370)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.processRequest(TCPHandler.java:555)
         at com.evermind.server.jms.TCPHandler$JMSRequestHandler.process(TCPHandler.java:521)
         at com.evermind.server.jms.TCPHandler.run(TCPHandler.java:204)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
         at java.lang.Thread.run(Thread.java:619)
    "Thread-19" daemon prio=10 tid=0x0000000045f54800 nid=0x2757 waiting on condition [0x0000000043873000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
         at java.lang.Thread.sleep(Native Method)
         at oracle.jdbc.pool.OracleImplicitConnectionCacheThread.run(OracleImplicitConnectionCacheThread.java:85)
    "Thread-17" daemon prio=10 tid=0x0000000045f5a800 nid=0x2755 waiting on condition [0x0000000043671000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
         at java.lang.Thread.sleep(Native Method)
         at oracle.jdbc.pool.OracleImplicitConnectionCacheThread.run(OracleImplicitConnectionCacheThread.java:85)
    "Thread-15" daemon prio=10 tid=0x0000000045f59800 nid=0x2753 waiting on condition [0x0000000043570000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
         at java.lang.Thread.sleep(Native Method)
         at oracle.jdbc.pool.OracleImplicitConnectionCacheThread.run(OracleImplicitConnectionCacheThread.java:85)
    "Timer-6" prio=10 tid=0x00002aab4463b800 nid=0x2751 in Object.wait() [0x000000004346f000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
         at java.lang.Object.wait(Native Method)
         - waiting on <0x00002aaabf31c868> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:509)
         - locked <0x00002aaabf31c868> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "VM Thread" prio=10 tid=0x000000004512a000 nid=0x270d runnable
    "GC task thread#0 (ParallelGC)" prio=10 tid=0x00000000450b8800 nid=0x2709 runnable
    "GC task thread#1 (ParallelGC)" prio=10 tid=0x00000000450ba800 nid=0x270a runnable
    "GC task thread#2 (ParallelGC)" prio=10 tid=0x00000000450bc800 nid=0x270b runnable
    "GC task thread#3 (ParallelGC)" prio=10 tid=0x00000000450be000 nid=0x270c runnable
    "VM Periodic Task Thread" prio=10 tid=0x00000000452da000 nid=0x2718 waiting on condition
    JNI global references: 3476
    Heap
    PSYoungGen total 717696K, used 558827K [0x00002aab0e200000, 0x00002aab3e200000, 0x00002aab3e200000)
    eden space 652224K, 84% used [0x00002aab0e200000,0x00002aab2f9bac88,0x00002aab35ef0000)
    from space 65472K, 15% used [0x00002aab35ef0000,0x00002aab368f0000,0x00002aab39ee0000)
    to space 62336K, 0% used [0x00002aab3a520000,0x00002aab3a520000,0x00002aab3e200000)
    PSOldGen total 1310720K, used 783099K [0x00002aaabe200000, 0x00002aab0e200000, 0x00002aab0e200000)
    object space 1310720K, 59% used [0x00002aaabe200000,0x00002aaaedebecb8,0x00002aab0e200000)
    PSPermGen total 135168K, used 134152K [0x00002aaaae200000, 0x00002aaab6600000, 0x00002aaabe200000)
    object space 135168K, 99% used [0x00002aaaae200000,0x00002aaab6502318,0x00002aaab6600000)
    I've pasted just certain extracts of the dump file. What is causing all these threads to wait? Any information on how to interpret this log file will be really helpful!
    Thanks,
    Anita

    It was caused by the 2nd threads' classloader.
              The 2nd thread uses the bootstrap classloader by default when attached to jvm, which loads the 'core' java classes only, not even extended classes.
              <p>
              This cause JNDI factory initialization failed.
              <p>
              The solution is to set the 2nd thread's context loader as the system class loader using JNI. See java.lang.Thread#setContextLoader and java.lang.ClassLoader#getSystemClassLoader.

  • Where to find old thread/post and closed the thread

    where to find old thread/post and closed the thread
    i try to search by email id, by userid but no results display at all only new post are shown

    Hi,
    where to find old thread/post and closed the thread
    i try to search by email id, by userid but no results display at all only new post are shownMake sure that u have specified the Correct date range parameter as required.
    Regards,
    X A H E E R

  • Threads: implement runnable or extend Thread.  Which is better?

    I want to know which way is better, as I want to do some work in threads.
    Thanks,
    Virum

    I want to know which way is better, as I want to do
    some work in threads.
    Thanks,
    VirumOne reason for implementing runnable can be that java doesnot allow multiple inheritance so by implementing runnable you can, at the same time, extend another class.
    Another reason though not recommended and not good programming practice is that although you cannot restart a dead thread, if you use runnables, you can submit the old runnable instance to a new thread, thus practically starting a thread more than once.

  • Selecting next thread broken after deleting previous thread since yesterday

    I read large mailboxes for mailing lists with threading enabled, and generally have the threads collapsed.
    Starting yesterday, when I delete a thread (or single message), it now starts to select the next thread, but then unselects everything after something like 3/4 of a second.
    That's if the thread is collapsed. If its not collapsed, it now selects ALL the messages in the thread instead of the initial summary pseudo-message giving the index of the messages in the thread. Apparently, if the thread is collapsed, it can't do that, and it gives up.
    It used to select the index of the thread. This selecting all the messages (and not the index) is not useful in any way I can imagine.
    How do I get the old behavior back?
    Thanks!

    I just saw the "Sort by Date" drop-down menu - it allowed me to sort by ascending date, so now I can do what I want.  Sorry about the ignorant post.
    tom

  • Thread sends notify() before waiting thread says wait()

    In the code below the ref book I'm using "Sun certified Programmer for Java 2" had the calculator thread starting before the Reader thread was even created and hence the calculator thread was finished it's task and sending a notify() before the Reader even had it's socks on and saying wait()
    ( And this cost me a lot of time tryin to figure this problem out as the code must have being written for a Z80 processor and not a 2.4GHz P4)
    To fix this I put the calculator starting after the reader thread, but .......
    I would have thought that java would have some protection against this happening, ie, like a notify flag which a thread can set if it has done it's job BEFORE the waiting thread even starts waiting, ie a preemptive mechanism to help speed things up ?
    package MyPackage;
    public class Reader extends Thread {
    Calculator MyCalculator;
    public Reader(Calculator calc){
    MyCalculator = calc;
    public void run(){
    synchronized(MyCalculator){
    try{
    System.out.println("Waiting for calculation ... ");
    MyCalculator.wait();
    }catch (InterruptedException e){}
    System.out.println("Total is: " + MyCalculator.total);
    public static void main(String args []){
    Calculator calculator = new Calculator();
    //calculator.start();
    new Reader( calculator ).start();
    calculator.start();
    package MyPackage;
    public class Calculator extends Thread{
    int total;
    public void run(){
    synchronized(this) {
    for(int i=0; i<100; i++){
    total += i;
    System.out.println("Calculation complete, notifying waiting thread..");
    notify();

    It's up to the 'umble programmer to code it right. The code you quoted was crap.
    The most common way to wait is on a condition:
    while (hotAndBotherd())
        obj.wait();And then the notifying thread will take steps to change that:
    //code that cools off the hot and bothered
    obj.notify[all]();If the initial state of things is hot and bothered then there is no race condition: the first thread will wait.

  • My macbook pro won't sleep - if I select sleep it does so initially, then the disc-drive appears to kick in and it comes back to life.  It also won't turn off (again, the disc drive kicks in) unless you hold the power-button down for a long period.

    My macbook pro won't sleep - if I select sleep it does so initially, then the disc-drive appears to kick in and it comes back to life.  It also won't turn off (again, the disc-drive kicks in) unless you hold the power-button down for a long period.  Help?

    Hi a,
    Try an SMC Reset: http://support.apple.com/kb/HT3964

  • How to post messages between two threads other than GUI main thread?

    Does anyone have examples of post messages between two threads (other than GUI main thread)?  Would you please post the link?
    Thank you,

    Hello, you can call PostDeferredCallToThread passing the your data in callbackData parameter.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Javafx Multi Threading - How to stop a thread

    Hi,
    I'm working on a Javafx and Java based chat client. To avoid GUI freezing I have put all "business logic" calls to Java using the Runnable feature. Everyting works ok, but when for example disconnecting the chat client I would also like to stop this specifc thread, avoid building up unused threads. I have tried using .stop() but it looks like its being ignored.
    Here my code:
    main.fx:
    progressIndicator.visible = true;
            var listener = FXListener_interface_connection {
                        override function callback(errorCode, errorMessage): Void {
                            //do something
                            if (errorCode != 200) {
                                setIcn(errorMessage);
                            } else {
                                progressIndicator.visible = false;
                                imageView9.visible = true;
                                openMessageListener();
                                rosterListener();
                                var ooo = ScaleTransition {
                                            duration: 0.2s
                                            node: imageView9
                                            byX: 0.6 byY: 0.6
                                            repeatCount: 8 autoReverse: true
                                ooo.play();
            var connect = FXListener_connection {
                        listener: listener
                connect.start();listener_connection.fx:
    public class FXListener_connection extends JavaTaskBase {
        public var listener: FXListener_interface_connection;
        protected override function create() : RunnableFuture {
            new Java_callback_connection(listener);
    }connection_interface.java
    public interface FXListener_interface_connection {
        public void callback(Integer errorCode, String errorMessage);
    }connection_callback.java
    public class Java_callback_connection implements RunnableFuture {
        private static FXListener_interface_connection listener_interface_connection;
        public Java_callback_connection(FXListener_interface_connection listener_interface_connection) {
            this.listener_interface_connection = listener_interface_connection;
        @Override
        public void run() throws Exception {
            //call function xmpp_connect()
            static_variables.xmpp.xmpp_connect();
        public static void connection(final Integer errorCode, final String errorMessage) {
            Entry.deferAction(new Runnable() {
                @Override
                public void run() {
                    listener_interface_connection.callback(errorCode, errorMessage);
    }

    jdevel doesn't let me debug;
    public class ProgressBarModel extends BoundedRangeModel {
    BooleanValueWrapper stopFlag = new BooleanValueWrapper(false);
    BooleanValueWrapper stopFlag2 = new BooleanValueWrapper(false);
    IntValueWrapper value = new IntValueWrapper(0);
    Thread newProgress = null;
    Thread newProcessFile = null;
    public void start(ActionEvent e) {
    value.setValue(0);
    stopFlag.setValue(false);
    ProgressSimulator progressSimulator = new ProgressSimulator();
    newProgress = new Thread(progressSumulator);
    newProgress.start();
    ProcessFileThreadMe processFileThreadMe = new ProcessFileThreadMe();
    newProcessFile = new Thread(processFileThreadMe);
    newProcessFile.start();
    class ProgressUpdater implements Runnable
    public void run(){
    try
    System.out.println(" ProgressUpdater is running");
    //stop fag is true if it is set to true or if value is equals or greater
    //than maximum
    try { 
    stopFlag.setValue(stopFlag.getValue() == true? true : (value.getValue() < maximum? false:true));
    //run in loop until stop condition is met. Make sure system doesn't
    //fail if values are initially set to the same value
    while (!stopFlag.getValue() && value.getValue() != maximum) {
    newProgress.interrupt();
    newProgress = null;
    } catch(Exception e) {
    stopFlag.setValue(true);
    stopFlag2.setValue(true);
    class ProcessFileThreadMe implements Runnable
    public void run(){
    System.out.println(" ProcessFileThreadMe is running");
    try
    if(stopFlag2.getValue() == true) {
    // interrupt this thread
    // set it to null
    return;
    bean.persisit(value, stopFlag);
    newProcessFile.interrupt();
    newProcessFile = null;
    catch (Exception exc)
    stopFlag.setValue(true);
    stopFlag2.setValue(true);
    exc.printStackTrace();
    In the bean the v alue is incremented
    Edited by: user597294 on Jul 21, 2011 6:33 AM

  • Is there a way to just sleep the display to sleep in 10.6 w/o system prefs?

    I just got a 2009 24 inch iMac, running os 10.6.
    Is there a way to just sleep the display to sleep in 10.6 without having to change the energy setting in system prefs?
    I'm used to a separate display attached to a tower. I work as a photographer and I like to keep my monitor display on when I'm working so it is warmed up, but I want to turn off the display only when I'm not working.
    I would like to keep the computer running since other computers on my network need to access it for files and backup, but I would like to just sleep the display.
    There is a 3rd party widget named Display Sleep, but it doesn't seem to work with 10.6.
    Any suggestions in how to sleep the display easily?

    Hi Gregory
    Go to: *System Preferences > Exposé and Spaces* > select the Exposé tab and setup an *Active Screen Corner* to *Put Display to Sleep*.
    http://www.maclife.com/article/howtos/gosleepnow
    http://www.ofzenandcomputing.com/zanswers/924
    Dennis

  • Menu and Thread.sleep(5000) or Thread.currentThread.sleep(5000)

    Hi,
    I am using JMenu and switchable JPanels.
    When I click on a MenuItem the follownig code should starts
        cards.add(listenPanel,  "listenPanel");
        cardLayout.show(cards, "listenPanel");
        try{
          Thread.sleep(5000); //in ms
          PlayMP3Thread sound = new PlayMP3Thread("sound/ping.mp3");
        } catch(Exception e) {
          e.printStackTrace();
        }It seems to be what I want to reach, but it does not work the way I want it to.
    I would like the Panel to show right away, then wait 5s and then play the sound.
    BUT what it does is freez the unfolded menu for 5s, then plays the sound and after that it shows the new Plane.
    Can you tell me why this is??

    This might be what you want
    package tjacobs.thread;
    import java.awt.Dimension;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.concurrent.Semaphore;
    import tjacobs.ui.Eyes;
    import tjacobs.ui.util.WindowUtilities;
    public class ThreadForMultipleAnytimeRuns extends Thread {
         private Runnable mRunnable;
         private Semaphore mSemaphore;
         public ThreadForMultipleAnytimeRuns(Runnable arg0) {
              super();
              init(arg0);
         private void init(Runnable r) {
              mRunnable = r;
              mSemaphore = new Semaphore(0);
              setDaemon(true);
         public ThreadForMultipleAnytimeRuns(Runnable arg0, String arg1) {
              super(arg1);
              init(arg0);
         public ThreadForMultipleAnytimeRuns(ThreadGroup arg0, Runnable arg1, String arg2) {
              super(arg0, arg2);
              init(arg1);
         public void run () {
              try {
                   while (!isInterrupted()) {
                        mSemaphore.acquire();
                        mRunnable.run();
              catch (InterruptedException ex) {}
         public void runAgain() {
              mSemaphore.release();
         public void runAgain(int numTimes) {
              mSemaphore.release(numTimes);
         public void stopThread() {
              interrupt();
         public int getSemaphoreCount() {
              return mSemaphore.availablePermits();
         public Runnable getRunnable() {
              return mRunnable;
         //The setRunnable method is simply not safe, and
         //trying to make it safe is going to effect performance
         //Plus I can't really see a gain in being able to set
         //The runnable on one of these threads. Just create
         //a new one!
         public synchronized void setRunnable(Runnable r) {
              if (getSemaphoreCount() > 0) {
                   try {
                        wait();
                   catch (InterruptedException ex) {
                        return;
              mRunnable = r;
         public static void main(String[] args) {
              final Eyes eyes = new Eyes(true);
              //eyes.addMouseMotionListener(eyes);
              Runnable r = new Runnable() {
                   public void run() {
                        eyes.blink();
                        try {
                             Thread.sleep(100);
                        catch(InterruptedException ex) {}
              final ThreadForMultipleAnytimeRuns ar = new ThreadForMultipleAnytimeRuns(r);
              ar.start();
              eyes.addMouseListener(new MouseAdapter() {
                   public void mouseClicked(MouseEvent me) {
                        ar.runAgain();
              eyes.setPreferredSize(new Dimension(60,20));
              WindowUtilities.visualize(eyes);
    //          JFrame jf = new JFrame();
    //          jf.add(eyes);
    //          jf.pack();
    //          jf.setLocation(100,100);
    //          jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //          jf.setVisible(true);
    }

  • Login on waking from sleep, but not screensaver / sleep display

    Hi all, been trying to get rid of the login from screen saver / sleep display, while keeping the login on waking the computer from sleep. The reason I want to do this is because I frequently use a Hot Corner to sleep the display while listening to music etc, and having to enter a password just to change tracks etc is a pain But obviously I want to keep the password protection when the computer is put to sleep, as it always is when left unattended.
    Anyway, based on initial Googling, I first tackled the problem by installing SleepWatcher from http://www.bernhard-baehr.de/, and adding this line to the global /etc/rc.wake script:
    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
    However, this wasn't very satisfactory, because after waking the computer up from sleep, you initially get a normal session, which then suspends after 3 or 4 seconds. During this time you can interact with the session as normal and move windows etc, so it kind of gives you the impression that you don't have to log in, and then you do, so it's a bit clunky, and also doesn't feel very secure.
    I thought I managed to improve the situation by moving the 'suspend' command to SleepWatcher's /etc/rc.sleep script instead of the /etc/rc.wake script - meaning that your session is suspended just before sleep, so it's already suspended when you wake the computer up. But then I noticed an even worse problem - my "Sleep Display" Hot Corner stopped working after SleepWatcher suspended my session!
    Yes that's right, every time the 'suspend' command ran in conjunction with SleepWatcher, my "Sleep Display" Hot Corner got disabled, and didn't get re-enabled until I completely logged out and back in (or rebooted). So I stopped using SleepWatcher, by removing the 'suspend' command from any SleepWatcher scripts, and now Hot Corners work as normal again following successive sleeps.
    So next I thought, maybe I could write an AppleScript that toggles the "Require password..." checkbox in System Preferences, perhaps to use in conjunction with SleepWatcher, so that the checkbox is disabled when the display is put to sleep, and enabled when the computer is put to sleep. I actually got as far as writing an AppleScript that toggled the checkbox, and was about to attempt to integrate it with SleepWatcher...
    ...then I stumbled across an old thread, where they talk about updating plists under com.apple.screensaver, in order to solve a slightly different problem:
    http://forums.macosxhints.com/showthread.php?t=14085
    Despite the thread being a few years old and trying to solve a different problem, the following command sounded hopeful so I thought I'd try it:
    defaults -currentHost write com.apple.screensaver askForPassword -int 0
    ...and lo and behold, it works!
    My mac is now behaving exactly as I want it - prompting for password on wake from sleep in the normal way as it did before, and not prompting when I merely wake the display (or screensaver)!
    This is in conjunction with having the "Require password to wake this computer from sleep or screen saver" checkbox turned ON in System Preferences.
    But the puzzling thing is, why does it work? Is it safe? Are there any side-effects and am I likely to need to re-enable it following software updates? Does it work for anyone else?
    When I query the values under com.apple.screensaver, I get the following... I have no way of telling what the askForPassword value was before I changed it:
    $ defaults -currentHost read com.apple.screensaver
    askForPassword = 0;
    idleTime = 0;
    moduleName = Flurry;
    modulePath = "/System/Library/Screen Savers/Flurry.saver";
    tokenRemovalAction = 0;
    Basically I'm very surprised that a simple one-line command seems to solve the problem, when there are so many threads where people have asked the same question, and either been told it's not possible, or told you need to do weird stuff with SleepWatcher and/or Applescript, which is often incompletely explained, more complex and less effective.
    So, is the one-line askForPassword solution too good to be true?

    Thanks. I think for an office-type environment, it is an unusual requirement.
    But let's not forget, more and more people use their computers in living-room type environments, for tasks such as playing music or watching films on a remote display. You're typically in a much darker ambience, which you don't want that to be shattered by the bright, white glare of a computer screen all the time!
    So you need total control over whether the display is on or off. This has nothing to do with leaving the computer unattended. You're still there, "using" the computer, you're just not necessarily using the display.
    Anyway... you are right, I toggled the "Require password..." setting in System Preferences off and then on again, and the "askForPassword" plist value changed itself to 1.
    However... the behaviour of my mac has not changed. It behaves the way I want it (prompt for password on waking the compuer, but not on waking only the display), regardless whether the value of askForPassword is 0 or 1.
    Even after rebooting.
    Strange... what have I done?

  • Sleep Mode/ Hibernation/Deep Sleep

    Hi,
    I recently bought my MacBook, I haven ever owned one before. And Was trying to find a way to turn off the AUTO sleep feature that occurs. I wouldn't mind if it kept me on-line, but it logs me off etc. Is there a way to fix this? I unchecked the box under the preferences to stop it from turning off the hard drive, but it appears to still do this. Is there something else I should be doing?
    I just want to stop it from going to sleep (aka stay on 24-7).

    Welcome to the forum.
    Check it here. http://discussions.apple.com/thread.jspa?messageID=4288706&#4288706
    oops,it's too much... Have you putted ''put computer to sleep when it's inactive for'' : Never ?

  • To sleep or not to sleep

    I have been reading a lot of articles lately about the good and bad of having disk drives spin up and then spin down (?), warm up, cool off, etc.
    What does Apple recommend for their computers (Intel iMac in particular), should we let them run all the time or have them sleep after 15 minutes being idle?

    It seems to me Pondini has answered the question. I went and checked. Page 24 of my 'little booklet,' that came with my Late 2009 Mac mini says: *"If you'll be away from your Mac mini for less than a few days, put it to sleep."*
    If away for 'more than a few days,' 'little booklet' says shut it down.
    It also indicate the choice is up to the user.
    I use my computer everyday, so, thus, absorbing this info means I should not Shut It Down...but let it go to Sleep. This would be not only convenient but make my computer usage more fun and effective. I use eight Spaces on Expose, and have two monitors and have 'learned,' to bounce around with stuff all over the place -- so if everything stays ON all the time, it would be so much easier to pick up where I left off and jump right in.
    So, I'm gonna do it. Sleep only (unless on vacation). My hinderance has been that I'm older than dirt and have some 'Old School,' attitudes like, you should turn things off when not using them. (D'uh).
    But I now vow to change my ways and get into Modern Times. If the Apple booklet says it; it says it.
    Plus, even back at the Dawn of Electricity I had a friend who worked for GE and he'd talk about (also mentioned in this thread) that there was 'wear and tear,' and power surge consumption associated with turning things on and off.
    Also mention (and I concur) is you don't want any equipment overheating -- so I have a fan directly set up to blow on my Mac (and my previous G5); this is a good idea, imo. So I'll let it sleep but also leave the fan on. I've calculated (using Numbers) that my retirement pension and the Earth can both afford this.
    Apple recommended temperature ranges for your room and/or environment are 50-90ºF (10-35ºC).
    Temperature ranges for the CPU's, Hard Drive Bay, etc. are much higher than I imagined. A freebie program Temperature Monitor -- and/or it's Lite version gives that info. TM Lite is one of my start up items, stays in the menu bar and the default for it's alarm (which I've set) is 75º C -- which strikes me a hot, darn hot. And right not the hotest reading I have is 57ºC and I've learned not to worry about it.
    Like also mentioned in this thread: Enjoy your Mac!

Maybe you are looking for

  • Quicktime encoding using x264 encoder failing in AME 6.0.2.81 and Mac OS 10.8.2

    I'm trying to encode an x264 codec Quicktime using AME 6.0.2.81 and Mac OS 10.8.2. I also tried it with two versions of the x264 encoder which I downloaded from here: http://www.macupdate.com/app/mac/24173/x264encoder This encoder works 100% fine and

  • Will OSX Tiger on a Quicksilver boot from a 300 g HD

    I have a few issues going and for background you can go to this post http://discussions.apple.com/thread.jspa?threadID=278373&tstart=0 But I have 4 internal HDs. And my Powermac Dual 800 will only boot from either the CD or the Tiger OS on my 80 gig

  • Comments don't appear in sidebar

    My client sends me comments and they appear as a list in a page below, rather than in the Comments sidebar. I don't know what to request them to do so I can see them in the sidebar and cut and paste the edits. I'm using 11.0.04; not sure what they ar

  • How do you add a source to the Health app?

    How do you add a source (ie, Nike +) to the new Health app?

  • F.5D, F.5E

    Hi i want to know the purpose of F.5D and F.5E. Can it add a profit center to a debit line? we have  a posting of Dr Customer 100 CR Revenue  100   Profit center 200 After we run the F.5D and F.5E will i see the profit center showing on the customer