Wednesday, September 30, 2015

GIT - 'git reset' my explanation

When and how to use git reset.

Case 1:
You have commited changes, but not yet pushed it. (never reset shared (pushed) commits, read this)
AND
You want to undo this commit and continue to work on these changes in it.
git reset --soft HEAD~1

Case 2:
You have commited changes, but not yet pushed it. (never reset shared (pushed) commits, read this)
AND
You want to undo this commit and DO NOT WANT to continue to work on these changes in it.
git reset --hard HEAD~1
In this case all changes of this commit will be lost and you will not see it in your Local Changes list (e.g. in InteleJIdea IDE)

HEAD~1 means 'one commit from HEAD'

Tuesday, September 22, 2015

THREAD - how to stop running thread

private volatile Thread blinker;

    public void stop() {
        blinker = null;
    }

    public void run() {
        Thread thisThread = Thread.currentThread();
        while (blinker == thisThread) {
            try {
                Thread.sleep(interval);
            } catch (InterruptedException e){
            }
            repaint();
        }
    }

http://docs.oracle.com/javase/7/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html

JAVA COLLECTIONS framework structure


Friday, September 11, 2015