List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:edu.stanford.junction.sample.sql.SQLActor.java
public static void main(String[] argv) { try {/*from w w w . j a v a2 s. c o m*/ System.out.println("Starting the database actor"); JSONObject activity = new JSONObject(); activity.put("sessionID", "sqlQuerySession"); activity.put("ad", "edu.stanford.prpl.junction.demo.sql"); XMPPSwitchboardConfig config = new XMPPSwitchboardConfig("prpl.stanford.edu"); JunctionMaker jm = JunctionMaker.getInstance(config); Junction jx = jm.newJunction(new ActivityScript(activity), new SQLActor()); /* try { Thread.sleep(3000); JSONObject msg = new JSONObject(); msg.put("query","select count(*) from jz_nodes"); jx.sendMessageToSession(msg); } catch (Exception e) { e.printStackTrace(); } */ Object dud = new Object(); synchronized (dud) { dud.wait(); } } catch (Exception e) { System.err.println("fail."); e.printStackTrace(); } }
From source file:VarArgsDemo.java
public static void main(String[] args) { process(System.out, "Hello", "Goodbye"); process(System.out, 42, 1066, 1776); process(System.out, "Foo", new Date(), new Object()); }
From source file:com.itmanwuiso.checksums.FileDuplicateChecker.java
public static void main(String[] args) { sync = new Object(); tasks = 0L;//from w ww .j a v a 2s. co m if (!setSettings(args)) { System.exit(-1); } int cores = Runtime.getRuntime().availableProcessors(); cores = cores + 1; prepare(cores, storageFile); run(); }
From source file:nz.co.jsrsolutions.ds3.DataScraper3.java
public static void main(String[] args) { logger.info("Starting application [ ds3 ] ..."); ClassPathXmlApplicationContext context = null; try {/* ww w . j a v a 2 s .c om*/ CommandLineParser parser = new GnuParser(); CommandLine commandLine = parser.parse(CommandLineOptions.Options, args); if (commandLine.getOptions().length > 0 && !commandLine.hasOption(CommandLineOptions.HELP)) { StringBuffer environment = new StringBuffer(); environment.append(SPRING_CONFIG_PREFIX); environment.append(commandLine.getOptionValue(CommandLineOptions.ENVIRONMENT)); environment.append(SPRING_CONFIG_SUFFIX); context = new ClassPathXmlApplicationContext(environment.toString()); context.registerShutdownHook(); if (commandLine.hasOption(CommandLineOptions.SCHEDULED)) { Scheduler scheduler = context.getBean(SCHEDULER_BEAN_ID, Scheduler.class); scheduler.start(); Object lock = new Object(); synchronized (lock) { lock.wait(); } } else { DataScraper3Controller controller = context.getBean(CONTROLLER_BEAN_ID, DataScraper3Controller.class); controller.executeCommandLine(commandLine); } } else { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ds3", CommandLineOptions.Options); } } catch (DataScraper3Exception ds3e) { logger.error("Failed to execute command", ds3e); } catch (ParseException pe) { logger.error("Failed to parse command line", pe); } catch (Exception e) { logger.error("Failed to execute command", e); } finally { if (context != null) { context.close(); } } logger.info("Exiting application [ ds3 ] ..."); }
From source file:com.sm.replica.grizzly.DefaultReplicaServer.java
public static void main(String[] args) { String[] opts = new String[] { "-store", "-path", "-port", "-mode", "index" }; String[] defaults = new String[] { "replica", "./data", "7120", "0", "0" }; String[] paras = getOpts(args, opts, defaults); String store = paras[0];//from w w w . j a v a 2 s . co m int port = Integer.valueOf(paras[2]); String path = paras[1]; int mode = Integer.valueOf(paras[3]); int index = Integer.valueOf(paras[4]); CacheStore cacheStore = new CacheStore(path, null, mode); LogChannel logChannel = new LogChannel(store, index, path); DefaultReplicaServer defaultReplicaServer = new DefaultReplicaServer(logChannel, index, store, path); HashMap<String, CacheStore> storesMap = new HashMap<String, CacheStore>(); storesMap.put(store, cacheStore); UnisonFilter unisonServerFilter = new UnisonFilter(defaultReplicaServer); unisonServerFilter.setFreq(1); logger.info("start server at " + port); ReplicaServer server = new ReplicaServer(port, storesMap, unisonServerFilter); defaultReplicaServer.hookShutdown(); logger.info("set main thread to wait()"); try { //System.in.read(); Object obj = new Object(); synchronized (obj) { obj.wait(); } } catch (Exception io) { logger.error(io.getMessage(), io); } }
From source file:br.eti.kinoshita.xstream.Bird.java
public static void main(String[] args) throws Exception { XStream xs = new XStream(); File f = new File("/tmp/bird2.xml"); xs.registerConverter(new Converter() { public boolean canConvert(Class type) { return type.equals(Bird.class); }// w w w. ja v a 2s . co m public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { Object beak = null; Object feathers = null; while (reader.hasMoreChildren()) { reader.moveDown(); if (reader.getNodeName().equals("beak")) { beak = reader.getValue(); } if (reader.getNodeName().equals("feathers")) { feathers = reader.getValue(); } } Bird bird = new Bird(beak, feathers); return bird; } public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Bird bird = (Bird) source; writer.startNode("beak"); writer.setValue(bird.getBeak() == null ? "" : bird.getBeak().toString()); writer.endNode(); writer.startNode("feathers"); writer.setValue(bird.getFeathers() == null ? "" : bird.getFeathers().toString()); writer.endNode(); } }); Bird bird = new Bird(new Object(), new String("many")); String s = xs.toXML(bird); System.out.println(s); FileUtils.write(f, s); Bird anotherBird = (Bird) xs.fromXML(f); System.out.println(anotherBird); }
From source file:com.google.appengine.tools.pipeline.impl.util.JsonUtils.java
public static void main(String[] args) throws Exception { JSONObject x = new JSONObject(); x.put("first", 5); x.put("second", 7); debugPrint("hello"); debugPrint(7);//from w w w . ja v a2 s . co m debugPrint(3.14159); debugPrint(""); debugPrint('x'); debugPrint(x); debugPrint(null); Map<String, Integer> map = new HashMap<>(); map.put("first", 5); map.put("second", 7); debugPrint(map); int[] array = new int[] { 5, 7 }; debugPrint(array); ArrayList<Integer> arrayList = new ArrayList<>(2); arrayList.add(5); arrayList.add(7); debugPrint(arrayList); Collection<Integer> collection = new HashSet<>(2); collection.add(5); collection.add(7); debugPrint(collection); Object object = new Object(); debugPrint(object); Map<String, String> map1 = new HashMap<>(); map1.put("a", "hello"); map1.put("b", "goodbye"); Object[] array2 = new Object[] { 17, "yes", "no", map1 }; Map<String, Object> map2 = new HashMap<>(); map2.put("first", 5.4); map2.put("second", array2); map2.put("third", map1); debugPrint(map2); class MyBean { @SuppressWarnings("unused") public int getX() { return 11; } @SuppressWarnings("unused") public boolean isHot() { return true; } @SuppressWarnings("unused") public String getName() { return "yellow"; } } debugPrint(new MyBean()); }
From source file:UuidUtil.java
/** * Method main//ww w . j av a2 s . com * * * @param args * * @audience */ public static void main(String[] args) { System.out.println(UuidUtil.generateUuidMM()); System.out.println(UuidUtil.generateUuid()); System.out.println(UuidUtil.generateUuid(new Object())); }
From source file:com.lucidtechnics.blackboard.examples.cocothemonkey.CocoTheMonkey.java
public static void main(String[] _args) throws Exception { try {/*w w w . ja v a2s . c o m*/ final Blackboard blackboard = new Blackboard(); logger.info("Starting Coco The Monkey"); System.out.println("Starting Coco The Monkey"); Thread thread1 = new Thread(new Runnable() { public void run() { synchronized (blackboard) { try { blackboard.wait(); } catch (InterruptedException e) { } } for (int i = 0; i < 100; i++) { Monkey monkey = new Monkey("Coco-1-" + i); Mango mango = new Mango("Coco-2-" + i); Eagle eagle = new Eagle("Coco-3-" + i); Hunter hunter = new Hunter("Coco-5-" + i); blackboard.placeOnBlackboard(eagle); blackboard.placeOnBlackboard(mango); blackboard.placeOnBlackboard(monkey); blackboard.placeOnBlackboard(hunter); } } }); Thread thread2 = new Thread(new Runnable() { public void run() { synchronized (blackboard) { try { blackboard.wait(); } catch (InterruptedException e) { } } for (int i = 0; i < 100; i++) { Monkey monkey = new Monkey("Coco-4-" + i); Mango mango = new Mango("Coco-1-" + i); Eagle eagle = new Eagle("Coco-5-" + i); Hunter hunter = new Hunter("Coco-3-" + i); blackboard.placeOnBlackboard(eagle); blackboard.placeOnBlackboard(mango); blackboard.placeOnBlackboard(monkey); blackboard.placeOnBlackboard(hunter); } } }); Thread thread3 = new Thread(new Runnable() { public void run() { synchronized (blackboard) { try { blackboard.wait(); } catch (InterruptedException e) { } } for (int i = 0; i < 100; i++) { Monkey monkey = new Monkey("Coco-3-" + i); Mango mango = new Mango("Coco-5-" + i); Eagle eagle = new Eagle("Coco-4-" + i); Hunter hunter = new Hunter("Coco-2-" + i); blackboard.placeOnBlackboard(eagle); blackboard.placeOnBlackboard(mango); blackboard.placeOnBlackboard(monkey); blackboard.placeOnBlackboard(hunter); } } }); Thread thread4 = new Thread(new Runnable() { public void run() { synchronized (blackboard) { try { blackboard.wait(); } catch (InterruptedException e) { } } for (int i = 0; i < 100; i++) { Monkey monkey = new Monkey("Coco-2-" + i); Mango mango = new Mango("Coco-3-" + i); Eagle eagle = new Eagle("Coco-1-" + i); Hunter hunter = new Hunter("Coco-4-" + i); blackboard.placeOnBlackboard(eagle); blackboard.placeOnBlackboard(mango); blackboard.placeOnBlackboard(monkey); blackboard.placeOnBlackboard(hunter); } } }); Thread thread5 = new Thread(new Runnable() { public void run() { synchronized (blackboard) { try { blackboard.wait(); } catch (InterruptedException e) { } } for (int i = 0; i < 100; i++) { Monkey monkey = new Monkey("Coco-5-" + i); Mango mango = new Mango("Coco-4-" + i); Eagle eagle = new Eagle("Coco-2-" + i); Hunter hunter = new Hunter("Coco-1-" + i); blackboard.placeOnBlackboard(eagle); blackboard.placeOnBlackboard(mango); blackboard.placeOnBlackboard(monkey); blackboard.placeOnBlackboard(hunter); } } }); thread1.start(); thread2.start(); thread3.start(); thread4.start(); thread5.start(); try { Thread.currentThread().sleep(1000); } catch (Throwable t) { } synchronized (blackboard) { blackboard.notifyAll(); } Object object = new Object(); synchronized (object) { try { object.wait(); } catch (InterruptedException e) { } } } finally { } }
From source file:Main.java
public static void forceGCandWait() { Object obj = new Object(); WeakReference ref = new WeakReference<>(obj); obj = null;//from w w w . j a v a 2 s . c o m System.gc(); System.runFinalization(); /** wait for garbage collector finished*/ while (ref.get() != null) try { Thread.sleep(100); } catch (InterruptedException e) { } //System.gc(); }