Basic ~/.bashrc ~/.bash_profile tips thread

A lot of this is borrowed from other sites, including the wiki
This by no means all-inclusive, please add on anything interesting along this topic
About ~/.bash_profile and ~/.bashrc
disclaimer:  I don't use ~/.bash_profile or ~/.profile
there is plenty of documentation on the web on how to use these properly if you're interested
in fact, my ~/.bash_profile looks like this:
#!/bin/sh
### THIS IS A DUMMY FILE
### DON'T NEED TWO FILES TO DO ONE JOB
### LET'S CALL ~/.bashrc INSTEAD
source ~/.bashrc
Now, if you choose to go this method, there's a little trick you can do to eliminate ~/.bash_profile altogether  :twisted:
as root create file /etc/profile.d/bashrc.sh with contents:
#!/bin/sh
source ~/.bashrc
AND
chmod +x /etc/profile.d/bashrc.sh
Since /etc/profile executes everything in /etc/profile.d/ that is chmod executable, the little script we just created will cause ~/.bashrc to be read on every login... I personally prefer this method to the dummy ~/.bash_profile, but I keep both since I share my /home directory across distributions and not all distros are the same.
Now, on to the actual ~/.bashrc:
#!/bin/sh
### ALIASES
alias ls="ls --color"
alias ll="ls --color -lh"
alias la="ls --color -a"
alias pacs="pacsearch"
alias vim="vim -y"
alias nano="nano -w"
### NICE COLOR BASH PROMPT
function bash_prompt
local WHITE="[33[1;37m]"
local default="[33[0;39m]"
local BRIGHTGREEN="[33[1;32m]"
local GREEN="[33[0;32m]"
local CYAN="[33[0;36m]"
local GRAY="[33[0;37m]"
local RED="[33[0;31m]"
if [ `id -u` != "0" ]; then
PS1="${GREEN}u${CYAN}@${GREEN}h ${CYAN}w${WHITE} ${default}$ "
else
PS1="${RED}u${CYAN}@${GREEN}h ${CYAN}w${WHITE} ${default}$ "
fi
bash_prompt
### COLORIZE PACMAN (PACS)
pacsearch () {
echo -e "$(pacman -Ss $@ | sed
-e 's#current/.*#\033[1;31m&\033[0;37m#g'
-e 's#extra/.*#\033[0;32m&\033[0;37m#g'
-e 's#community/.*#\033[1;35m&\033[0;37m#g'
-e 's#^.*/.* [0-9].*#\033[0;36m&\033[0;37m#g' )"
This is really pretty basic.  I use the same ~/.bashrc for all users, including root...
The alias section is pretty self explanatory, basically the parts in quotations (" ") get run instead of the commands before the equals (=) in every case.
The bash prompt section is a bit nifty.  The first part, with color definitions, is so that I don't go mad trying to write the actual PS1 line.  Makes it cleaner in my opinion.  There's lots of documentation out there if you're interested in modifying the prompt I have.
The if/then/else statement in the bash prompt section checks if the user is root.  If not, the username is displayed in GREEN at the prompt.  If the user is root, the username is displayed in RED.  A nice visual reminder, and since I use my ~/.bashrc for ALL users, including root, it helps make the file more portable.
The last section is taken straight from the Arch wiki.  At the top I aliased 'pacs', which calls this section.  Basically 'pacs' can take the place of 'pacman -Ss' and offer simple colour output.
http://wiki.archlinux.org/index.php/Col … man_output
Additions, other bash tips & tricks, comments, all welcome

I added some comments explaining each piece.
Misc stuff:
# My prompt, quite basic, decent coloring, shows the value of $?
# (exit value of last command, useful sometimes):
C_DEFAULT="[33[0m]"
C_BLUE="[33[0;34m]"
export PS1="$C_BLUE($C_DEFAULT$?$C_BLUE)[$C_DEFAULTu$C_BLUE@$C_DEFAULTh$C_BLUE:$C_DEFAULTw$C_BLUE]\$ $C_DEFAULT"
export PS2="$C_BLUE> $C_DEFAULT"
# If you allow Ctrl+Alt+Backspace to kill the X server but are paranoid,
# then this alias will ensure that there will be no shell open afterwards.
alias startx="exec startx"
# Let grep colorize the search results
alias g="egrep --color=always"
alias gi="egrep -i --color=always"
# Hostname appended to bash history filename
export HISTFILE="$HOME/.bash_history_`hostname -s`"
# Don't save repeated commands in bash history
export HISTCONTROL="ignoredups"
# Confirm before overwriting something
alias cp="cp -i"
# Disable ^S/^Q flow control (does anyone like/use this at all?)
stty -ixon
# If your resolution gets fucked up, use this to reset (requires XRandR)
alias resreset="xrandr --size 1280x1024"
And some small but handy functions:
# mkmv - creates a new directory and moves the file into it, in 1 step
# Usage: mkmv <file> <directory>
mkmv() {
mkdir "$2"
mv "$1" "$2"
# sanitize - set file/directory owner and permissions to normal values (644/755)
# Usage: sanitize <file>
sanitize() {
chmod -R u=rwX,go=rX "$@"
chown -R ${USER}.users "$@"
# nh - run command detached from terminal and without output
# Usage: nh <command>
nh() {
nohup "$@" &>/dev/null &
# run - compile a simple c or cpp file, run the program, afterwards delete it
# Usage: run <file> [params]
run() {
filename="${1%%.*}"
extension="${1##*.}"
file="$1"
shift
params="$@"
command=""
if [ $extension = "cc" -o $extension = "cpp" -o $extension = "c++" ]; then
command="g++"
elif [ $extension = "c" ]; then
command="gcc"
else
echo "Invalid file extension!"
return 1
fi
$command -Wall -o $filename $file
chmod a+x $filename
./$filename $params
rm -f $filename 2>/dev/null

Similar Messages

  • Digital Camera Basic Picture-Taking Tips

    Digital Camera Basic Picture-Taking Tips 
    Get to know your new camera
    Read your instruction manual to familiarize yourself with your cameras features and settings.
    Protect your new camera
    Use the hand/neck strap that is included with your camera to prevent it from dropping. This will also ensure that the strap will stay out of your shots.
    Setting image resolution 
    Set your camera on the maximum resolution. You can always lower the resolution on your computer later, but you can never raise the resolution once it is taken.
    Set to Auto 
    While you are learning, set your camera on AUTO mode. This automates most settings such as shutter speed and whether a flash is used, allowing you to focus only on taking pictures.
    Focusing 
    Before taking your picture, hold the shutter button down half-way to auto focus the camera. Once it focuses it should give some signal by either flashing or beeping, which means that the camera is ready to snap the image.
    Composing your image 
    Use the LCD screen (or the viewfinder with a DSLR) to frame up your image before you take it, making sure you have everything you want in your picture. The rule of thirds is a good general composition technique that usually will produce better looking images. The rule of thirds suggests placing your subject one third into your composition rather than centering your subject.
    Keeping your images sharp 
    To prevent blurry pictures, hold your camera with both hands and keep your elbows close to your sides. In low light situations using a tripod will help make your images much sharper. Many digital cameras also have what is called image stabilization, and I would suggest making sure this feature is turned on if your camera has this feature.
    Make sure your subject is lighted properly 
    Keep lighting in mind since light is what is needed for a properly exposed image. Turn your flash on in low light situations.  Avoid taking pictures directly into the sun.
    Don’t run out of power 
    Keep extra batteries or bring your a/c adapter if you are traveling.
    More is better 
    Take LOTS of pictures! You aren’t wasting any film, and you can always delete images you don’t like.
    Allan|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

    Also remember to change your ISO back to 200-400 for bright sunshine shooting the day after you were in a bar taking band pics at 6400. Was wondering why the shots yesterday were blown over. Smacking myself in the back of the head for that one. Glad it was just 'fun' shooting yesterday and not paid for.
    King of the World...

  • Basic query in JAVA Threads....Please reply !!

    I have a class (say ABC) which extends Thread...This class basically
    reads some file which provides some start-time and stop-time information..
    File structure is like:-
    ===========================================
    <Entry1>Starttime = A and Stoptime = B
    ===========================================
    Logic is that thread sleeps till time A arrived, then do some operations (which are written
    in it's run() method) till stoptime..
    The object of ABC class is being constructed in some other class.
    Now there is a change....File can have multiple entries like..
    ======================================
    <Entry1>starttime = A and stoptime = B
    <Entry2>starttime = X and stoptime = Z
    <Entry3>starttime = A and stoptime = B
    <Entryn>starttime = X and stoptime = Z
    ======================================
    The start-time and stop-time of any two Entries can be same or different.
    The operations should start executing at the defined time..
    In this case, multiple threads are required, which can do the operations
    mentioned in Entry1,2 etc.....But how should it be implemented..
    My query is:-
    1) Can I have a common-wrapper class, which reads the file and based on
    the number of Entries, instantiates that much number of threads...
    But how to do that....I am new to JAVA...Should that class be a simple
    class...or should it also implement Thread/Runnable interface.....
    Or can I implement it as ThreadGroup......
    Please give soem suggestions....Thanks...

    e.g.
            ScheduledExecutorService exec = Executors.newScheduledThreadPool(2);
            exec.schedule(new Runnable() {
                public void run() {
                    runTask();
            }, delay, TimeUnit.MILLISECONDS);

  • Basic database maintenance tips

    hello friends
    i made a small database of my company and now have to maintain it,take backup etc..my question is that what are the first things that i have to do before start using the database as a production database
    thanx in advance

    saugat chatterjee wrote:
    yes we have made the database and now we have to use it in actual scenario from tomorrow onwards=================================================
    Learning how to look things up in the documentation is time well spent investing in your career. To that end, you should drop everything else you are doing and do the following:
    Go to tahiti.oracle.com.
    Drill down to your product and version.
    <b><i><u>BOOKMARK THAT LOCATION</u></i></b>
    Spend a few minutes just getting familiar with what is available here. Take special note of the "books" and "search" tabs. Under the "books" tab you will find the complete documentation library.
    Spend a few minutes just getting familiar with what <b><i><u>kind</u></i></b> of documentation is available there by simply browsing the titles under the "Books" tab.
    Open the Reference Manual and spend a few minutes looking through the table of contents to get familiar with what <b><i><u>kind</u></i></b> of information is available there.
    Do the same with the SQL Reference Manual.
    Do the same with the Utilities manual.
    You don't have to read the above in depth. They are <b><i><u>reference</b></i></u> manuals. Just get familiar with <b><i><u>what</b></i></u> is there to <b><i><u>be</b></i></u> referenced. Ninety percent of the questions asked on this forum can be answered in less than 5 minutes by simply searching one of the above manuals.
    Then set yourself a plan to dig deeper.
    - Read the 2-Day DBA guide
    - Read a chapter a day from the Concepts Manual.
    - Take a look in your alert log. One of the first things listed at startup is the initialization parms with non-default values. Read up on each one of them (listed in your alert log) in the Reference Manual.
    - Take a look at your listener.ora, tnsnames.ora, and sqlnet.ora files. Go to the Network Administrators manual and read up on everything you see in those files.
    - When you have finished reading the Concepts Manual, do it again.
    Give a man a fish and he eats for a day. Teach a man to fish and he eats for a lifetime.
    =================================

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • Having a problem with threads and using locks

    I was hoping someone could give me some hits on getting my code to run properly. The problem I am having is I think my locks and unlocks are not working properly. Plus, for some reason I always get the same output, which is:
    Withdrawal Threads         Deposit Threads            Balance
    Thread 2 attempts $29 Withdrawal - Blocked - Insufficient Funds
    Thread 4 attempts $45 Withdrawal - Blocked - Insufficient Funds
    Thread 6 attempts $34 Withdrawal - Blocked - Insufficient Funds
    Thread 7 attempts $40 Withdrawal - Blocked - Insufficient Funds
                                    Thread 1 deposits $187          $187
                                    Thread 3 deposits $169          $356
                                    Thread 5 deposits $61           $417
    Press any key to continue...If someone can see the error I made and doesn't mind explaining it to me, so I can learn from it, I would appreciate that very much.
    /************Assign2_Main.java************/
    import java.util.concurrent.*;
    public class Assign2_Main
    {//start Assign2_Main
        public static void main(String[] args)
        {//start main
               // create ExecutorService to manage threads
               ExecutorService threadExecutor = Executors.newCachedThreadPool();
            Account account = new SynchronizedThreads();
            Deposit deposit1 = new Deposit(account, "Thread 1");
            Deposit deposit2 = new Deposit(account, "Thread 3");
            Deposit deposit3 = new Deposit(account, "Thread 5");
            Withdrawal withdrawal1 = new Withdrawal(account, "Thread 2");
            Withdrawal withdrawal2 = new Withdrawal(account, "Thread 4");
            Withdrawal withdrawal3 = new Withdrawal(account, "Thread 6");
            Withdrawal withdrawal4 = new Withdrawal(account, "Thread 7");
            System.out.println("Withdrawal Threads\t\tDeposit Threads\t\t\tBalance");
            System.out.println("------------------\t\t---------------\t\t\t-------\n");
            try
                threadExecutor.execute(withdrawal1);       
                threadExecutor.execute(deposit1);     
                threadExecutor.execute(withdrawal2);  
                threadExecutor.execute(deposit2);    
                threadExecutor.execute(withdrawal3);
                threadExecutor.execute(deposit3);       
                threadExecutor.execute(withdrawal4);
            catch ( Exception e )
                 e.printStackTrace();
                //shutdown worker threads
               threadExecutor.shutdown();
        }//end main
    }//end Assign2_Main/******************Withdrawal.java****************************/
    public class Withdrawal implements Runnable
    {//start  class Withdrawal
          *constructor
        public Withdrawal(Account money, String n)
             account = money;
             name = n;
        public void run()
        {//start ruin
             int newNum = 0;
                newNum = account.getBalance(name); 
               Thread.yield();
        }//end run
        private Account account;
        private String name;
    }//end  class Withdrawal/*******************Deposit.java***************/
    import java.util.Random;
    public class Deposit implements Runnable
    {//start class Deposit
          *constructor
        public Deposit(Account money, String n)
             account = money;
             name = n;
        public void run()
        {//start run
                try
                     Thread.sleep(100);
                   account.setBalance(random.nextInt(200), name);
                }// end try
                catch (InterruptedException e)
                  e.printStackTrace();
       }//end run
       private Account account;
       private Random random = new Random();
       private String name;
    }//end class Deposit/********************Account.java*****************/
    *Account interface specifies methods called by Producer and Consumer.
    public interface Account
         //place sum into Account
         public void setBalance(int sum, String name);
         //return  value of Account
            public int getBalance(String name);         
    } /**************SynchronizedThreads.java****************/
    import java.util.concurrent.locks.*;
    import java.util.Random;
    public class SynchronizedThreads implements Account
    {//start SynchronizedThreads
          *place money into buffer
        public void setBalance(int amount, String name)
        {//start setBalance
             // lock object
             myLock.lock();           
            sum += amount;
            System.out.println("\t\t\t\t" + name + " deposits $" + amount +"\t\t$"+ sum+"\n");       
               //threads are singnaled to wakeup
            MakeWD.signalAll();
              // unlock object                                                
            myLock.unlock();
           }//end setBalance
            *gets the balance from buffer
           public int getBalance(String name)
        {//start getBalance
             int NewSum = random.nextInt(50);
             //lock object
            myLock.lock();
            try
                 if(sum > NewSum)
                     //takes NewSum away from the account
                     sum -= NewSum;
                        System.out.println(name + " withdraws $" + NewSum +"\t\t\t\t\t\t$"+ sum+"\n");
                else
                     System.out.println(name +  " attempts $" + NewSum + " Withdrawal - Blocked - Insufficient Funds\n");                 
                     //not enough funds so thread waits
                        MakeWD.await();         
                //threads are singnaled to wakeup
                MakeD.signalAll();     
                }//end try
            catch (InterruptedException e)
                   e.printStackTrace();
            finally
                 //unlock object
                 myLock.unlock();
            return NewSum;     
         }//end getBalance
         private Random random = new Random();  
         private Lock myLock = new ReentrantLock();
         private Condition MakeD = myLock.newCondition();
         private Condition MakeWD = myLock.newCondition();
         private int sum = 0;
    }//end SynchronizedThreads

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • "Portable" way to do message passing between threads?

    (I posted this on the Apple Developer Forums already, but since that forum is only accessible to registered and paid iPhone developers, I thought it would be nice to put it here as well so as to get some more potential eyeballs on it. I apologize if this kind of "cross-posting" is not kosher/is frowned upon around here.)
    Hey everybody,
    "Long-time listener, first-time caller," heh.
    I've been working for the past 2-3 months on my very first iPhone app. Actually, what I've been working on is a framework that I plan to use in an iPhone app of my own but which I am also trying to write for the "lowest-common-denominator" so that I (and others) can use it in other apps written for both Mac and iPhone.
    Not only is this my first time writing an iPhone app, it is my first time writing for any Apple platform. In fact, it is my first time using Objective-C, period. I cannot stress this enough: I am a "n00b." So go easy on me. I also have not worked with threading before this, either, on any platform, so the learning curve for me here is rather significant, I'm afraid. I am NOT afraid of either taking the time to learn something properly OR of rolling up my shirtsleeves and working. However, on account of my experiences so far, I am finding myself (not to flame or anything!) quickly becoming frustrated by and disillusioned with not so much Objective-C itself, but the Foundation frameworks.
    So with that said, read on, if you dare...
    The basic idea behind my project is that the framework I am writing will present an API to developers which will allow them to write client apps that interact with a particular network appliance or network-aware embedded system. I already have my basic set of classes up and functioning, and the framework works to my satisfaction both on MacOS and iPhoneOS. The platforms I am targeting are MacOS X Tiger 10.4 and later, and iPhoneOS, and up until this point, I've managed to keep a codebase that works on all of the above.
    What I wanted to do next was add some multithreaded goodness to the mix. (Woe is me.) I have asynchronous network socket I/O working within the main thread, and it, in fact, works a treat. In my test app on the phone, I've managed to keep the UI nice and responsive by using the main thread's runloop efficiently. But even though TCP async I/O works fine within the main thread, I want to be able to split out and offload the processing of any data received by the app from the appliance to its own thread. (It is possible, and even desirable, for an application using this framework to be connected to multiple appliances simultaneously.)
    My idea, in order to try to keep things as simple and as clean as possible, was to implement a wrapper class that presented my other main class as an "actor." So, rather than instantiating my main class, one would create an instance of the wrapper class which would in turn control a single instance of my main class and spawn its own thread that the network connection and all data processing for that particular connection would run within.
    (I hope I'm making sense so far...)
    Out of the gate, writing a subclass of NSThread sounds like the logical design choice for an "actor-type" thread, but because I was trying to maintain Tiger compatibility, I stuck with +detachNewThreadSelector:etc.
    Once I decided to pursue the actor model, though, the main problem presented itself: how to best pass messages between the main thread and all of the "actor" threads that might be spawned?
    I stumbled upon -performSelector:onThread:withObject:, and knew instantly that this was exactly what I was looking for. Unfortunately, it doesn't exist on Tiger; only its much more limited little brother -performSelectorOnMainThread:withObject: does. So I kept looking.
    All of the pre-Leopard documentation, tutorials, and sample code that I read indicated that to pass messages between threads, I needed to basically pretend that the threads were separate processes and use the expensive Distributed Objects mechanism to get messages back and forth. Unfortunately, even if that WAS a desirable option, iPhoneOS does not have any support for DO! Grrr...
    Finally, I thought I found the answer when I ran into a third-party solution: the InterThreadMessaging library from Toby Paterson (available @ http://homepage.mac.com/djv/FileSharing3.html). In this library, the author basically implemented his own version of -performSelector:onThread:withObject: called -performSelector:withObject:inThread:. Sounds close enough, right? And actually, it is pretty darn close. It's made to do exactly what it sounds like, and it does it in a platform-neutral way that works on pre-Leopard systems as well as iPhoneOS, using Mach ports instead of DO.
    (...wellll, ALMOST. I discovered after I built a small test app around it that it actually isn't "iPhone-clean." The author used an NSMapTable struct and the NSMap*() functions, which don't exist in iPhoneOS, and he also implemented the handlePortMessage delegate method, but although iPhoneOS has NSPort, it DOESN'T have NSPortMessage. GAAARGH. So I took the time to replace the NSMapTable stuff with NSValue-wrapped objects inside of an NSMutableDictionary, and replaced the handlePortMessage method implementation with a handleMachMessage method, which took some doing because I had to figure out the structure of a Mach message, NO thanks to ANY of the available documentation...)
    Once I started using it, though, I quickly discovered that this implementation wasn't up to snuff. My "actor" class and my main thread will be passing a ton of messages to each other constantly whenever there is network activity, and with InterThreadMessaging, I found that whenever activity started to ramp up, it would collapse on itself. This mostly took the form of deadlocks. I found a note that someone else wrote after experiencing something similar with this library (quoted from DustinVoss @ http://www.cocoadev.com/index.pl?InterThreadMessaging):
    "It is possible to deadlock this library if thread A posts a notification on thread B, and the notification on B causes a selector or notification to be posted on thread A. Possibly under other circumstances. I have resolved this in my own code by creating an inter-thread communication lock. When a thread wants to communicate, it tries the lock to see if another thread is already using the InterThreadMessaging library, and if it can't get the lock, it posts a message to its own run-loop to try again later. This is not a good solution, but it seems to work well enough."
    So I tried implementing what he described using a global NSLock, and it did help with some of the deadlocks. But not all. I believe the culprit here is the Mach ports system itself (from the NSPortMessage documentation for -sendBeforeDate:):
    "If the message cannot be sent immediately, the sending thread blocks until either the message is sent or aDate is reached. Sent messages are queued to minimize blocking, but failure can occur if multiple messages are sent to a port faster than the portís owner can receive them, causing the queue to fill up."
    InterThreadMessaging in fact calls -sendBeforeDate: and exposes the deadline option, so I tried setting a really short time-to-live on the Mach messages and then intercepted any NSPortTimeoutExceptions that were thrown; upon catching said exceptions, I would then re-queue up the message to be sent again. It worked, but Performance. Was. A. Dog. At least the message queue wouldn't be full indefinitely anymore, causing the main thread to block, but during the whole time that these messages were expiring because the queue was full and then being re-queued, either the main thread was trying to send more messages or the actor thread was trying to send more messages. And as far as I can tell, the Mach ports queue is global (at the very least, there is seemingly only one per process). The message would get through with this model...eventually.
    JUST IN CASE the problem happened to be something I screwed up as I was rewriting portions of the InterThreadMessaging library so that it would compile and work on the iPhone SDK, I substituted in the original version of the library in my Mac test app to see if any of these problems became non-issues. I found that both versions of the library -- mine and the original -- performed identically. So that wasn't it.
    Finally, in frustration I said, "screw it, I'm going to try it the Leopard way," and replaced all of the method calls I was making to InterThreadMessaging's -performSelector:withObject:inThread: with calls to Foundation's native -performSelector:onThread:withObject: instead, changing nothing else within my code in the process. And wouldn't you know: IT WORKED GREAT. Performance was (and is) fantastic, about on-par with the non-threaded version when only dealing with a single connection/instance of my class.
    So, in the end, I was able to do nothing to salvage the InterThreadMessaging implementation of cross-thread method calling, and as far as I can tell, I'm out of (good) options. And thus my mind is filled with questions:
    How is the Leopard -performSelector:onThread: method implemented? I'm guessing not using Mach ports, given that I didn't have the same blocking & deadlocking problems I had with InterThreadMessaging. Is it possible to re-implement this Leopard+ method in a similar manner as a category to NSObject under Tiger? Or is it possible, perhaps, to increase the size of the Mach ports queue so that InterThreadMessaging works at a sane level of performance? Or -- I'm getting desperate here -- is there any way that I could trick -performSelectorOnMainThread: to target a different thread instead? (I am assuming here that -performSelectorOnMainThread is implemented under-the-hood much like the new -performSelector:onThread: is implemented, but with a hard-coded NSThread pointer built-in to the code, and that the new method just exposes a more flexible interface to what is basically the same code. I'm probably wrong...) Is there another third-party library out there that I've missed that fits my requirements for being able to do message-passing between threads in an efficient and portable manner?
    I refuse to believe that there is no way for me to maintain compatibility with all of the platforms I wish to support without having to resort to making preprocessor #ifdef spaghetti out of my code. And there SURELY has to be a better way of doing cross-thread message passing in Tiger without using Distributed Objects, for Pete's sake! Is this really how people did it for years-on-end since the dawn of NeXT up until the advent of Leopard? And if there really, genuinely wasn't another alternative, then what is up with the lack of DO in iPhoneOS?? Does Apple seriously intend for developers who have good, solid, tested and working code to just chuck it all and start over? What if there was some aspect of DO that previous implementations relied upon that cannot be recreated with simple -performSelector:onThread: calls? (I don't know what those aspects would be...just a hypothetical.) I mean, I can understand needing to write new stuff from scratch for your UI given how radically different the interface is between the Mac and iPhone, but having to reimplement back-end guts such as something as elemental as threads...really?!
    I do laud the inclusion of the new method in Leopard as well as the new ability to subclass NSThread itself. But for those of us that need to support Tiger for one reason or another, some of these restrictions and omissions within iPhoneOS seem like rather pointless (and frustrating) roadblocks.
    As I hope is obvious here, I have tried to do my homework before throwing up my hands and pestering y'all. If you have the patience to deal with me, please tell me what I am missing.
    Thanks for taking the time to read,
    -- Nathan

    Thanks again for your patience. Comments below.
    etresoft wrote:
    It is pretty unusual that anyone would want to call perfomrSelector on any thread other than the main thread.
    What I described in my original post was not a worker thread, but an "actor."
    It is hard for me to answer this question because there are so many options available to do "message passing". The fact that you think there are so few tells me that you really aren't sure what you need to use.
    I didn't say there were few options for message passing. I said there were few options for message passing that fit my criteria, which are that any potential solutions should both A) work efficiently and with good performance, and B) be available both pre-Leopard AND on the iPhone. -performSelector: ain't available before Leopard. Distributed Objects is overkill. Kernel Mach messages apparently have a high overhead, too, as my experience with the third-party library I wrote about in my original message shows.
    ...consider notifications.
    I thought notifications couldn't be posted across threads, either. How do I post a notification to another thread's default notification center or notification queue from a different thread?
    The notification center is owned by the process. Each run loop can listen for just the notifications it wants. You don't "pass" or "send" notifications, you run then up the flagpole for all to see.
    I am aware of how to use notifications. The documentation for NSNotificationCenter clearly states that "In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself."
    So, again, I don't see how one thread can post a notification in such a way that the observer's registered method is executed in another thread (posting notifications "across threads"). This probably isn't a big deal if you are using mutexes (assuming you don't actually care which thread carries out the task associated with the notification posting), but as I said before, this is not what I'm after.
    I don't know what you are really after.
    Allow me to attempt to explain a second time, in a more concise fashion.
    My app will have multiple, persistent TCP connections open, one connection per remote device. The user will be able to select a task to execute on a particular device that we have a connection open to, and get back from the application real-time updates as to the progress or results of the execution of that task. In certain cases, the length of the task is infinite; it will keep executing forever and sending back results to my application which will update its display of the results every second that ticks by until the user STOPS that particular task.
    This can be done simply using async I/O in the main runloop, sure. But if I were going to thread this so that I could be processing the results I've received back from one *or more* remote devices while also doing something else, given that I will only have one (persistent) connection open to any given remote device that I'm interacting with (that is to say, I won't be opening up a separate TCP session for every single task I want to execute on a single device simultaneously), it makes sense _to me_ to implement this as I've described: with every connection to each remote device getting its own thread that lasts for the lifetime of the TCP session (which could be the entire time the application is running, times however many devices the user wishes to be connected to while in the app). I won't be spawning a new thread for every task the user wishes to ask a remote device to do.
    This is why (I think) I need bi-directional messaging between the main thread and each of these threads dedicated to a given remote device that we have an active session with/connection to. The main thread needs to be able to tell remote device X (which already has a running thread dedicated to it) to do task A, and then get real-time feedback from that remote device so that the main thread can be displaying it to the user as it is coming back. Same with remote device Y running task B, simultaneously. At any time during the execution of these tasks, the user needs to be able to tell my app to stop one of these tasks, and the main thread needs to send that message to one of the remote devices via that device's dedicated thread.
    This is why I am talking about this in terms of the "actor model," and not the "worker thread model," because the former model seems to fit what I want to do.
    -- Nathan

  • What does it mean to be "thread safe"?

    What does it mean to be "thread safe"?
    I am working with a team on a project here at work. Someone here suggested that we build all of our screens during the initialization of the application to save time later. During the use of the application, the screens would then be made visible or invisible.
    One of the objections to that idea was that the swing components (many of which we use) are not thread safe. Can anyone tell me what the relevance of that is?
    Thanks

    To understand why Swing is not thread safe you have to understand a little bit of history, and a little bit of how swing actually works. The history(short version) is that it is nearly impossible to make a GUI toolkit thread safe. X is thread safe(well, sorta) and it's a really big mess. So to keep things simple(and fast) Swing was developed with an event model. The swing components themselves are not thread safe, but if you always change them with an event on the event queue, you will never have a problem. Basically, there is a Thread always running with any GUI program. It's called the awt event handler. When ever an event happens, it goes on an event queue and the event handler picks them off one by one and tells the correct components about it. If you have code that you want to manipulate swing components, and you are not ON the awt thread(inside a listener trail) you must use this code.
    SwingUtilities.invokeLater( new Runnable() {
      public void run() {
        // code to manipulate swing component here
    });This method puts the defined runnable object on the event queue for the awt thread to deal with. This way changes to the components happen in order, in a thread safe way.

  • Swing/Threads, changing the GUI

    Hey all, I have a question related to the java swing class, and manipulating a GUI which is something that I have never done before. Basically I have a threaded Listener class which returns a status boolean. Related to that status, I have a Jlabel which is supposed to display green if the status is true, and red if the status is false, however it is not working correctly. Below is my code, and I would appreciate some help if anyone has a fix, or better way to do this... Thanks in advance
    //Listener Class
    public class Listener extends Thread{
         private boolean isGood = false;
         public Listener(//...) {
         public void run()
              // does stuff here that sets the isGood var
         public bool getIsGood()
              return this.isGood;
    //GUI
    public class Visualizer {
         private static Listener listener;
         public Visualizer(Listener listener){
              this.listener = listener;
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
         private static JFrame frame;
         private static JLabel status;
         public static void createAndShowGUI() {
    //Create and set up the window.
    frame = new JFrame("Window");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    status = new JLabel("Listener... ");
    status.setOpaque(true);
    status.setBackground(Color.RED);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    frame.setSize(new Dimension(204, 115));
    frame.setContentPane(status);
    listener.start();
    while(true){
         boolean isGood = listener.getIsGood();
    if(isGood){
    status.setBackground(Color.GREEN);
    else{
    status.setBackground(Color.RED);
         try{
              Thread.sleep(1000);
         }catch(Exception E){
              E.printStackTrace();
    I purposely left out some of the code because I wanted to make it simpler to follow. Essentially this is what is going on, and hopefully someone can point out why its not working and how to fix it. Thank you for reading this.

    thanks for the advice Petes, I was looking for the code tag before but didnt see it. I have created an SSCCE, and I apologize for not making it earlier. Here is the code. The threads seem to be getting stuck, and the label doesnt alternate between red and green as it should. Let me know if you need anything else:
    package simplified;
    public class Main{
         public static void main(String[] args) {
              Listener theListener = new Listener();
              theListener.start();
              Visualizer theView = new Visualizer(theListener);
    //Listener Class
    public class Listener extends Thread{
         private boolean isGood = false;
         public Listener() {
         public void run(){
              if(this.isGood == true){
                   this.isGood = false;
              else{
                   this.isGood = true;
              try{
                   this.sleep(1000);
              }catch(Exception e){
                   e.printStackTrace();
         public boolean getIsGood(){
              return this.isGood;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.Dimension;
    public class Visualizer {
         private static Listener listener;
         public Visualizer(Listener listener){
         this.listener = listener;
         javax.swing.SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                   createAndShowGUI();
         private static JFrame frame;
         private static JLabel status;
         public static void createAndShowGUI() {
              //Create and set up the window.
              frame = new JFrame("Window");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              status = new JLabel("Listener... ");
              status.setOpaque(true);
              status.setBackground(Color.RED);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
              frame.setSize(new Dimension(204, 115));
              frame.setContentPane(status);
              while(true){
                   boolean isGood = listener.getIsGood();
                   if(isGood){
                        status.setBackground(Color.GREEN);
                   else{
                        status.setBackground(Color.RED);
                   try{
                        Thread.sleep(1000);
                   }catch(Exception E){
                        E.printStackTrace();
    }

  • Some questions on interrupts, threads etc

    Havng gone through some documentation on interrupt, kernel level threads etc in WDF, I got a couple of questions:
    1)  Can a hardware interrupt be preempted by another interrupt in a single processor system?
    2)  What exactly is the difference between thread preemption and thread interrupt? Doesnt both mean stopping the current thread and putting it aside?
    3)  When an iterrupt is handled by an ISR, does the ISR always have to  schedule  a DCP? If the ISR itself can handle the interrupt, is the DPC needed?
    4) I understand that spin locks are used for synchronisation at IRQL <=DISPATCH_LEVEL. EVT_WDF_IO_QUEUE_IO_WRITE works at <= DISPATCH_LEVEL. If I set Synchronisation scope of a write queue as SynchronisationScopeQueue, should I still go for a spin
    lock, if the write callback and say an ioctl callback uses a shared resource?
    5 )Kernel dispatcher objects are mutex, timer, event, semaphore etc. But If i use a fast mutex or guarded mutex or oridinary mutex using say, KeAcquireFastMutex() isnt that then a kernel dispatcher object? What this distinction?  Why should we go explicitly
    go for kernel dispatcher object?
    6) How can timers be used for kernel level synchronisation? How different is this from timers created using WdfTimerCreate()?
    7)  It is said that "Never wait on a kernel dispatcher object in any driver routine that can be called at IRQL>=DISPATCH_LEVEL.". Does it mean
    we should not use synchronisation mechanisms in this level? Or if we can use, should the thread try to acquire a lock with  a zero wait time? And proceed if it could acquire the lock and return if the lock was not acquired?
    8) I understand that in order to execute an interrupt, a driver does not create any special threads but use a thread that happens to be running at the moment( arbitrary thread ) . My question is, in what way is this accomplished? What aspect of the arbitrary
    thread is the interrupt using ? The arbitrary thread must obviously have been written for another purpose.

    To answer the questions:
    #1   An interrupt service routine (ISR) running a lower IRQL may be interrupted by another ISR running at a higher level.
    #2   Having never heard of a thread interrupt, all I can say here is that a thread may be pre-empted for a lot of reasons.
    #3   An ISR does not have to schedule a DPC unless it needs to do work that it cannot do at high IRQL.
    #4   Assuming that the Write and IOCTL are on seperate queues, yes you need a a lock to protect shared resources.
    #5   As the name implies kernel dispatcher objects allow scheduling (i.e. dispatching of another thread), while things like spinlocks do not. 
    #6    Timers are just another dispatching object, i.e. one can wait on them the same way one waits on a mutex or a semaphore.  A WDF TIMER is basically a wrapper around a regular timer to take care of some of the housekeeping (particularily
    with respect to stopping the driver etc)
    #7     If a routine is running at DISPATCH_LEVEL you are limited to spin locks for synchronization. You can with a zero timeout check the status of a kernel dispatcher object.   In general, routines like this should be
    designed to only use spinlocks.
    #8    An arbitrary thread is just that, it may be a thread in any process. Basically a currently running thread is grabed and used to run the interrupt so that the scheduler which has overhead and is not designed to run at interrupt level
    IRQL's does not need to run.
    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

  • TIP: Create Linear Multipage controls

    Post Author: jeminar
    CA Forum: Xcelsius and Live Office
    Creating a single flash file with multiple "pages" that mean you can move from one to the next took us a long time to figure out, and we could not figure it out based on googling, this forum, or tech support at BO.A flash file with lots of tabs is shown in some of the examples, where each tab directs you to a new flash file. However, this is no good if the tabs are dependent on the inputs from previous pages, unless you store the results on a database and access them again.A solution we came up with is to create a linear multipage. This is a series of pages where you have to move through the pages in sequence, and each page has a Previous and Next button on it. (Except, of course the first page and the last page which don't have Previous and Next respectively).We created an extra page in Excel called something like "page control", and on each "page" we added 2 toggle buttons which represent the Previous and Next buttons. You format the On and Off positions of the toggle buttons to be the same, so when the user clicks, they don't realize that the button has changed state.The value of each of these buttons links to a cell on this "page control" sheet. In order to determine which page you are on, you apply the following rules, by deriving the following formulas on the page control sheet.A cell for TRUE when the toggle button state from Page 1 Next is the same as Page 2 PreviousAnother cell for TRUE when the toggle state from Page 2 Next is the same as Page 3 previousetc. You can have as many pages as you like.Note: each cell refers to the relationship between two adjacent sheets, so you end up with (n-1) TRUE/FALSE values if you have n "pages". In order to determine which page you are on, create a final cell which has:=COUNTIF(range with these TRUE/FALSE values,FALSE)The value of this cell with the COUNTIF formula states which page the user is on, and you set dynamic visibility based for the contents of each page based whether the page number equals this one.So far, we have not figured out how to allow users to move between "pages" at will, e.g. with a navigation bar.We are using this for two things: (1) for a quick survey, where there are a few pages of inputs followed by a calculated output; (2) for a tool which allows people to dig deeper into specific aspects of data.Now: we would love to know how to have a multipage that is controlled by a Navigation Bar. 

    Urmm, I'm not sure about the Fruityloops thing, but anyway...
    Tips like this are great. It's a shame that we can't get a sticky thread or something for ideas like this. I think the problem with posting tips like this is that not everyone has the time to try it straight away, and quite often when they have a bit of time, the post has already joined the page 2 darkness... It would be really great to be able to have a tips thread where people could post, and you could delve into at your leisure. I know there's that one with lots of Audacity Works stuff in it, but I was thinking a Logic specific one that everyone could contribute to. I'm sure that lots of people have already suggested thing like this, but then again, maybe it's better to let them get on with the new forum and not bother them for a bit hehe.
    Best, Fred

  • APP for a free MODERN DAY calculator and tip calculator​????!!

    The calc on the bb stock is SO basic! No tip calc etc like other current phones,.,even my old voyager and en touch had one! help! thank you.

    swanky13 wrote:
    ... they said I must have accidently purchased a in app I find this difficult to believe due to my password being needed! I find this difficult to believe due to my password being needed!
    Which is pretty much a reasonable assumption.And you do not neccessarily need a password for an in app purchase.
    swanky13 wrote:
    I emailed iTunes and they have not replied to my email -
    Yes, considering all of the traffic they get, it may take them a while. Have you tried using this: http://www.apple.com/support/itunes/contact/
    swanky13 wrote:
    I'm going to post this on every social network and email them 10 times a day until I get a refund,
    Which demonstrrates muchmore about your imaturity than anything about Apple. And BTW, it won't work.
    swanky13 wrote:
    - but it's the principal- anyone else been ripped off with a similar con!!!??????
    What con? Even if it is an error on Apple's system, there's no indication of dishonesty (and I refer back to the first item).

  • Parallel function call and thread issue

    Sorry to post one issue here which is related to code. i was debugging a code which was wrote long time back by one developer. the issue is two function is called parallel using thread and one function set a variable true at end and another function just
    looping until the variable is set to true. the variable value is not getting set to true. here i am posting a code snippet and just tell me what is mistake in the code for which variable is not getting set to true by first function.
    when user click button then two function is invoked
    private void UPDATE_Click(object sender, System.EventArgs e)
    SavedFirst();
    AddCheckThread();
    public void SavedFirst()
    IsOpen = true;
    System.Threading.Thread loadT = new System.Threading.Thread(new System.Threading.ThreadStart(SaveAll));
    loadT.Start();
    IsOpen = false;
    private void AddCheckThread()
    if (!ALLFlag)
    loadingThread = new System.Threading.Thread(new System.Threading.ThreadStart(addCheck));
    loadingThread.Priority = System.Threading.ThreadPriority.Lowest;
    loadingThread.Start();
    private void SaveAll()
    if (this.InvokeRequired)
    this.Invoke(new MethodInvoker(delegate
    ALLFlag = false;
    if (!ALLFlag)
    loadingThread = new System.Threading.Thread(new System.Threading.ThreadStart(AddProducts));
    loadingThread.Priority = System.Threading.ThreadPriority.Lowest;
    loadingThread.Start();
    return;
    private void AddProducts()
    if (this.InvokeRequired)
    this.Invoke(new MethodInvoker(delegate
    ALLFlag = false;
    if (System.Windows.Forms.MessageBox.Show(this, "Would you like to add the details into the Database?", "Add?", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
    if (comboOUR.SelectedItem == null || comboCountry.SelectedItem == null || comboSelleble.SelectedItem == null || txtOereff.Text == "" || txtUKPrice.Text == "" || txtUSPrice.Text == "" || txtSUrCharge.Text == "" || txtOURUS.Text == "" || txtOURUK.Text == "")
    FormValidation();
    else
    Gather_Data();
    bool isInserted = false;
    if (System.Windows.Forms.MessageBox.Show(this, "Would you like to add the details into \"Detailed-Product\" Too?", "Add?", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
    isInserted = bbaProduct.BBASaveProduct();
    if (isInserted == true)
    isInserted = false;
    isInserted = bbaProduct.InsertInProductTable(BBAProduct.DetailProductID);
    if (isInserted == true)
    System.Windows.Forms.MessageBox.Show(this, "Product Successfully Added ", "Add");
    else
    System.Windows.Forms.MessageBox.Show(this, "Error Occurred !! Not Added Into the Database ", "Add");
    else
    System.Windows.Forms.MessageBox.Show(this, "Error Occurred !! Not Added Into the Database ", "Add");
    else
    isInserted = bbaProduct.InsertInProductTable(0);
    if (isInserted == true)
    System.Windows.Forms.MessageBox.Show(this, "Successfully Inserted Into the database", "Add");
    else
    System.Windows.Forms.MessageBox.Show(this, "Error Occurred !! Not Added Into the Database", "Add");
    else
    System.Windows.Forms.MessageBox.Show(this, "Process Cancelled By The User", "Add");
    ALLFlag = true;
    return;
    #region Add Check
    private void addCheck()
    if (this.InvokeRequired)
    this.Invoke(new MethodInvoker(delegate
    this.Opacity = 0.8;
    axShockwaveFlash1.Visible = true;
    axShockwaveFlash1.Play();
    while (!ALLFlag)
    int x = 0;
    axShockwaveFlash1.Visible = false;
    axShockwaveFlash1.Visible = false;
    axShockwaveFlash1.StopPlay();
    this.Opacity = 1;
    ALLFlag = false;
    loadingThread.Abort();
    return;
    help me to locate where is the mistake for which ALLFlag value is not getting set to true. thanks

    Your reliance on a field value across threads isn't going to work reliably.  In a multi-core/multi-threaded world the memory model allows for reading data out of order for optimization reasons.  Additionally the CPU can and will cache recently
    used data in memory that isn't shared across processors.  This can get you into trouble as you will not be reading the same value across processors.
    The only correct way to ensure that multiple threads access the same data correctly is to use sync objects that are designed for that such as a Semaphore or Mutex.  Sync objects allow you to safely share data across threads.
    Overall your code appears to be trying to update the UI using a thread but since it is calling Invoke each time you are basically spawning a thread that then blocks waiting for the UI thread.  You could pretty much eliminate your issues by getting rid
    of the threading calls altogether along with any sort of state management variables that were arbitrarily created (ALLflags) and simply use BeginInvoke.  You didn't post who was calling your higher level save methods but if it is a UI element then BeginInvoke
    and InvokeRequired are completely redundant as is all the threading.
    You can cleanly update this code to eliminate all the extra variables and threading and simply use the newer async/await functionality to help resolve the issues your code is having.  But you still have problems with the invoked code.  In one of
    the methods you are looping while waiting for a variable to be set.  But since you invoked it then it is occurring on the UI thread.  Because it is on the UI thread and that can only do 1 thing at a time, if ALLflag is false your code will deadlock. 
    The only other code that would set it to true cannot run because it is also invoked on the UI thread and only one of them can run at any one time.  Basically each of your threads are going to try to run on the same thread and only 1 of them will be able
    to.  Until the first thread method finishes the second one will never run.
    If you need Boolean flags then consider using a ManualResetEvent instead.  It is thread safe, works across threads and doesn't have any of the problems of a Boolean field when talking about threading. But you still have a deadlock between your invoked
    code that nothing will solve except rewriting your code.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • How-to Basics or Help that doesn't...

    I've been away from Flash for almost 10 years and now that I'm returning I remember doing certain things but I can't remember HOW to do them.
    Back then I could open the Help file, search and quickly find an answer. NOW - I open the help file, search and get nothing but irrelevant answers when ALL I WANT is very basic instructions. I've tried the on-line tutorials and, while they help, they aren't comprehensive and often skip over very basic but crucial details. I've tried searching the forums and I get even more irrelevant notes. It seems that no one is asking basic questions or the threads that deals with the basics just don't show up in my search results.
    know that once I get started, it will all seem to be very simple but it's so hard to get started. There has got to be a better way.
    While I'm here, I may as well what ask for what I'm looking for - how to you apply a label to a frame?
    Thanks.

    Thank you - like I said, it's so obvious but I just didn't notice the label section under properties. This has taught me one more thing about CS4 - you have to look further than the menus when looking for answers.
    Thanks again.
    Grace

  • Tablet Security Tips

    It was reported that tablet shipments were estimated to be nearly 73 million units in 2011.  If you have one of those 73 million tablets or are preparing to purchase a tablet, remember, security starts at "home" with you, the tablet owner. 
    To protect your investment, keep these basic Tablet Security Tips in mind.
    Microsoft MVP, Consumer Security
    Take a walk through the "Security Garden" -- Where Everything is Coming up Roses!
    Twitter: http://twitter.com/SecurityGarden
    Security Information and Malware Removal @LandzDown Forum

    @Corrine,
    Any good software to recommend for tablets which enables GPS tracking if the device is stolen? Would prefer freeware without subscribing to any services but if need to pay for it then I don't mind too.
    Thanks =D
    *Non Lenovo employee*
    I have a Y2P (i5) ... Feel free to ping me if you want me to test some applications with your Y2P if you have the same model. I don't mind keep doing recovery on it if needed .... =)

Maybe you are looking for

  • How can i pass the logged in user attribute value into looku query ?

    HI, Is there any way to pass loggined in user attribute vallue to lookup query directrely in AD Child Group form.(Like '$Form data.UD_ADUSER_AD') Thanks in advance Edited by: 790561 on 5/12/2011 16:01

  • Autocomplete doesn't work for packages that were just installed

    After installing a program with pacman, I wasn't able to use autocomplete in bash or zsh for that program, even though I was able to run it. If I made a new terminal autocomplete worked fine, it was only in the terminal I had just used to install the

  • Input Help values

    Hi friends Is there any FM to get the input Help values ( fixed , check table values, search help values ) if i specify the field.

  • Downloading on Safari

    when looking to download a file i get this error message Safari could not download the file "FILE" because there is not enough free disk space. I switch to another location and i still get the same error message when i try to download whats the remed

  • JSP can't  "see" bean properties

    I am trying to populate my JSP form inputs using a bean. I know the bean properties are being set, but for some reason they are not being passed to my form inputs. The bean properties are being set by a worker class just prior to hitting the JSP that