This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tistory.devyongsik.termFrequency; | |
import java.io.IOException; | |
import org.apache.lucene.analysis.Analyzer; | |
import org.apache.lucene.analysis.standard.StandardAnalyzer; | |
import org.apache.lucene.document.Document; | |
import org.apache.lucene.document.Field; | |
import org.apache.lucene.document.Field.Index; | |
import org.apache.lucene.document.Field.Store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package blockingqueue; | |
import java.util.concurrent.BlockingQueue; | |
public class Consumer implements Runnable { | |
private BlockingQueue queue; | |
public Consumer(BlockingQueue queue) { | |
this.queue = queue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my %rule = (1=>2, 2=>3, 3=>5, 4=>7, 5=>11, 6=>13, 7=>17); | |
foreach my $k (keys %rule) { | |
print "$rule{$k}"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use DateTime; | |
use strict; | |
use warnings; | |
my $start_date = DateTime->new( | |
year=>1901, | |
month=>1, | |
day=>1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
startDate=Date.new(1901,1,1) | |
endDate=Date.new(2000,12,31) | |
startDate === endDate #비교, =가 3개 | |
startDate.wday == 0 #요일, 0이 일요일 | |
startDate.mday == 1 #month of day | |
startDate = startDate + 1 #하루 증가 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.pool2.impl.GenericObjectPool; | |
public class TestPool { | |
public static void main(String[] args) throws Exception { | |
for(int i = 0; i < 10; i++) { | |
GenericObjectPool genericObjectPool = new GenericObjectPool(new MyPoolableObjectFactory()); | |
MyPoolableObject obj = (MyPoolableObject)genericObjectPool.borrowObject(); | |
System.out.println("i : " + i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.pool2.BasePooledObjectFactory; | |
import org.apache.commons.pool2.PooledObject; | |
import org.apache.commons.pool2.impl.DefaultPooledObject; | |
public class MyPoolableObjectFactory extends BasePooledObjectFactory<MyPoolableObject> { | |
@Override | |
public MyPoolableObject create() { | |
return new MyPoolableObject(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyPoolableObject { | |
private static int id = 0; | |
public MyPoolableObject() { id++; } | |
public int getId() { return id; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.*; | |
public class FutureAndCallableExample { | |
public static void main(String[] args) throws InterruptedException, ExecutionException { | |
System.out.println("Main : " + Thread.currentThread().getName()); | |
ExecutorService executorService = Executors.newSingleThreadExecutor(); | |
Callable<String> callable = () -> { | |
System.out.println("Entered Callable"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Tester implements Runnable { | |
private Log logger = LogFactory.getLog(Tester.class); | |
int i = 0; | |
public Tester(int i ) { | |
this.i = i; | |
} | |
public void run() { |
NewerOlder