Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FastHashMap
- {
- public static class Loader extends Thread
- {
- private int from;
- private int to;
- private HashMap<Long, String> data;
- public Loader( final HashMap<Long, String> data, int from, int to )
- {
- this.data = data;
- this.from = from;
- this.to = to;
- start();
- }
- @Override
- public void run()
- {
- for( int i=from;i<=to;i++) {
- data.put( new Long(i), "#" + String.valueOf( i ) );
- }
- }
- }
- public static void main(String[] args)
- {
- HashMap<Long, String> data = new HashMap<Long, String>();
- new Loader( data, 1, 150 );
- new Loader( data, 100, 200 );
- try { Thread.sleep( 3000 ); } catch (InterruptedException noCare) {}
- System.out.println( data.size() );
- int miss = 0;
- for( int i=1;i<=200;i++)
- {
- if( !data.containsKey( new Long(i) ) ) miss++;
- }
- System.out.println( miss );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement