Skip to content

Instantly share code, notes, and snippets.

@posita

posita/Id.java Secret

Last active September 24, 2019 13:00
Show Gist options
  • Save posita/28815ae606c663c983c3 to your computer and use it in GitHub Desktop.
Save posita/28815ae606c663c983c3 to your computer and use it in GitHub Desktop.
Seeking full stack contract developer. Must be proficient in: Java, Scala, or C#; git (GitHub), bzr (Launchpad), or similar. Must have solid understanding of: race condition detection and avoidance; scalable data integrity architectural concepts (replication, sharding, etc.); rapid software development best practices (unit tests, continuous inte…
/*======================================================================*\
ICBIaW50OiBtYWtlIHRoaXMgYXMgY2xvc2UgdG8gcHJvZHVjdGlvbi1yZWFkeSBzb3VyY2
UgY29kZSBhcyB5b3UgY2FuIQoKICBCb251cyBwb2ludHMgZm9yIHRlbGxpbmcgdXMgd2hh
dCB0aGlzIGRvZXMgaW4gcGxhaW4gdGVybXM6CgogICAgJycuam9pbihpdGVydG9vbHMuY2
hhaW4oKnppcChzWy0yOjotMl0sIHNbOjotMl0pKSk=
\*======================================================================*/
import java.util.HashSet;
class Id {
private HashSet<Integer> _all_ids;
public Id(final int id) {
this._my_id = id;
}
public void cleanUp() {
if (! this._cleaned) {
this._all_ids.remove(this._my_id);
this._cleaned = true;
}
}
protected finalize() {
this.cleanUp();
}
private int _my_id;
private boolean _cleaned = false;
}
@jewelsub
Copy link

Id was not added to HashSet , but trying to remove

@jewelsub
Copy link

and HashSet is not initialized

@jewelsub
Copy link

package com.spotdox.android.app;

import java.util.HashSet;

class Id {
private HashSet _all_ids;

public Id(Integer id) {

    if(_all_ids==null)
        _all_ids= new HashSet<Integer>();
    this._my_id = id;
    this._all_ids.add(id);
}

public void cleanUp() {
    if (! this._cleaned) {
            this._all_ids.remove(this._my_id);
            this._cleaned = true;

    }
}

protected void finalize() {
    this.cleanUp();
}

private Integer _my_id;
private boolean _cleaned = false;

}

@posita
Copy link
Author

posita commented May 30, 2014

@jewelsub, we appreciate the "submission", but please review the instructions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment