Win a copy of Securing DevOps this week in the Security forum!

Henry Wong

+ Follow
since Sep 28, 2004
Henry likes ...
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
Forum Moderator
Henry Wong currently moderates these forums:
New York City
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Henry Wong

Mark Richardson wrote:So, I'm pretty proud that I intuitively came up with this sorting algorithm, but what type of algorithm is this exactly?

It looks like an inefficient bubble sort. To make it closer to the bubble sort algorithm, you can have the inner loop start at the outer loop index instead of zero. you can have the inner loop end index terminate at the final index minus the outer loop index.

6 hours ago

Xsi jadu wrote:
Could someone help me out?

Take a look at the PrintStream (class type of System.out) class' printf() method, or the String class' format() method.

10 hours ago

Niti Kapoor wrote:is net user command will run with custom password?

The net command is an administrative command, and you really should do direct research on it... as you really don't want to mess up your Windows accounts.

Windows net user command

10 hours ago
Windows lock screen will use the users password. And your users will really likely *not* want you changing their Windows password.... 

... but, still, if you want to know ... take a look at the net user command.

11 hours ago
The ScheduleExecutorService is used to run tasks on a schedule, and it could be any tasks... including...

Alex Zhou wrote:On page 347 of the OCP workbook by Jeanne and Scott, it says that the schedule() command can be used to check on the state of processing a task and send out notifications if it is not finished or even call schedule() again to delay processing.

You can schedule a different task, that is used to check on the status/health of the first task (to see if it completed), and then, if not, do stuff, like send out notification. Of course, the two tasks need to share information for it to happen.

Alex Zhou wrote:
Can somebody explain to me how those tasks can be done, especiallly the calling schedule() again to delay processing?

If a task determines that something can't be done yet, the task can schedule another task to "continue where it left off" at a later time. It can then finish (return) since the other task will execute later. This is, in effect, delaying processing -- although arguably, it is just stopping and letting another task finish processing later.

... and BTW, I have *not* read the book being referred to here. So, this is purely speculation. You will need to provide more context, if the question is more specific / related to the book.


This week, we're delighted to have Julien Vehent helping to answer questions about the new book Securing DevOps

The promotion starts Tuesday, Apr 24th, 2018 and will end on Friday, Apr 27th, 2018.

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, Manning.

Image from unknown

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.
1 day ago

Arun Singh Raaj wrote:When should i use static inner class and when should i use inner class?

You should use an inner class (static or otherwise), when you need an inner class. And you should use a static inner class, when you don't need access (or a linkage) to an outer class. Inner/Nested classes are simply tools. Trying to quantify their usage isn't very straightforward -- just like when to use a while loop versus a for loop. You use the correct tool when it makes sense, and that comes with experience.

2 days ago
Scheduled promotions:

Note: We can run more than one promo in a given week, so check for updates.

Starting DateCoverBookAuthor(s)PublisherCodeRanch Forum
April 24Securing DevOpsJulien VehentManningSecurity
May 1Kafka Streams in Action  Bill BejeckManningFunctional Programming
May 8Testing Java MicroservicesAlex Soto Bueno and Jason PorterManningWeb Services
May 15Available
May 22Available
May 29Available

Go back to the main BookPromotions page.
4 days ago

First, a big thanks to Simon Harrer, Jörg Lenhard, Linus Dietz for being here to promote the book Java by Comparison (eBook).

The winners are:

    Martin McNicholas
    Campbell Ritchie
    Norm Radder
    Timur Radzhabov

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Country (needed even if requesting an e-book)
Phone Number

Also, please include the following as the subject of your Email.

Book Promo Winner - Java by Comparison (eBook) - Tuesday, Apr 17th, 2018

Image from unknown

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.

4 days ago

Vaibhav Gargs wrote:
3. CMS - NOT Stop the World i.e. other application threads will continue their processing. IF this is the case, then we say in Serial & Parallel, that we have to stop the application to have integrity then how it is achieved in CMS then?

The new generation parallel collector is a copy garbage collector. Objects that are not collected are always moved -- either to the old generation heap, or to the other half of the new generation heap. The old generation CMS collector is a mark and sweep collector. It is actually done in two passes. The first pass just marks what is reachable, and the second pass is used to compact the objects (filling in the gaps).... Or another way to think about it ... these are two completely different garbage collectors, using completely different algorithms.

To answer your question, why does one algorithm have certain behavior issues, than a completely different algorithm? To be facetious, well, because they are different...

To be serious, I couldn't tell you. If you really are interested, the source code for OpenJDK is always available. I guess you can use that to learn the fine details of the algorithms, which may help you figure out the difference.

1 week ago

Vaibhav Gargs wrote:
And, Aren't they related to each other i.e. higher throughput means lower response time?

Here's an interesting analogy... Let's say that you are hungry, and desire an apple. And there is an Apple Orchard nearby. There are two options...

Option #1. You get a whole team of apple pickers (along with all the high end equipment). This team will pick all the ripe apples from the orchard, and then, come back to give you an apple.

Option #2. You get one apple picker (and a ladder). He/she goes and pick one apple, and then, comes back to give you an apple.

Questions. Which option picks the most apples per amount of time (ie. best throughput)? Which option gets you an apple faster (lower response time)?

1 week ago

Vaibhav Gargs wrote:
But, we say that Minor and Major GCs are Stop the World events and hence, application threads are stopped when it happens. So, how concurrent GC is different?

Concurrent means that it is *not* stop the world. It just blocks the thread waiting for memory until it is available. Parallel means that the collector is multi-threaded. It means that the GC can use more than one processor/core at a time.

1 week ago

And if you want a Garbage Collector that is both Parallel and Concurrent, then take a look at the Azul JVM.

1 week ago