Mac 打印如何设置为灰度打印(以佳能Canon E479,使用“预览”应用为例)

 mac  Mac 打印如何设置为灰度打印(以佳能Canon E479,使用“预览”应用为例)已关闭评论
12月 182021
 

Mac 打印时如何设置为灰度打印:

以佳能Canon E479,使用“预览”应用为例:

  1. 使用“预览”应用打开文档,并通过菜单打开 “打印 …”

2. 选择“质量与介质类型”,  不同的应用或打印机可能这边的描述不太一样。

3. 勾选“灰度打印”

直接点“打印”即可灰度打印。

4.  这样每次都要设置比较麻烦,可以将此设置保存为预设。 操作如下:选择“将当前设置存储为预置”

重命名:

此后选择这个设置即可

 

DONE!

理解线程池运行过程(ThreadPoolExecutor举例,打印线程池当前线程数、队列任务数、已完成数等信息)

 java  理解线程池运行过程(ThreadPoolExecutor举例,打印线程池当前线程数、队列任务数、已完成数等信息)已关闭评论
11月 292021
 

jdk提供了非常方便的方式来生成线程池, 如Executors.newxxxxxx的方式, 实现实际使用的都是以下ThreadPoolExecutor的方法:

/**
* Creates a new {@code ThreadPoolExecutor} with the given initial
* parameters.
*
* @param corePoolSize the number of threads to keep in the pool, even
* if they are idle, unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the
* pool
* @param keepAliveTime when the number of threads is greater than
* the core, this is the maximum time that excess idle threads
* will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are
* executed. This queue will hold only the {@code Runnable}
* tasks submitted by the {@code execute} method.
* @param threadFactory the factory to use when the executor
* creates a new thread
* @param handler the handler to use when execution is blocked
* because the thread bounds and queue capacities are reached
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
* @throws NullPointerException if {@code workQueue}
* or {@code threadFactory} or {@code handler} is null
*/

public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)

线程池的管理是这样一个过程:

首先创建线程池, 然后根据任务的数量逐步将线程增大到corePoolSize数量, 如果此时任有任务增加, 则放置到workQueue中, 直到workQueue爆满为止, 然后继续增加线程池中的线程数量,增加处理能力,最终达到maximumPoolSize。 如果此时还是有任务增加进来会怎样呢 ? 这就需要handler来处理了,或者丢弃新任务, 或者拒绝新任务,或者挤占已有任务等。在任务队列何线程池都饱和情况下,一旦有线程处于等待(任务处理完毕, 没有新任务增加)状态的时间超过keepAliveTime,则该线程终止, 也就是说池中的线程数量会足部降低, 直至为corePoolSize数量为止。 至于threadFactory,可以自己新增一个,设置线程的自定义名称, daemon状态,便于后续排查错误。

我们用一个测试程序来帮助理解线程池的运行过程:

public class ThreadPoolTest {

private static ExecutorService es = new ThreadPoolExecutor(50, 100, 0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(100000));

public static void main(String[] args) throws Exception {
for (int i = 0; i < 100000; i++) {
es.execute(() -> {
System.out.print(1);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});

}

ThreadPoolExecutor tpe = ((ThreadPoolExecutor) es);
while (true) {
System.out.println();
int queueSize = tpe.getQueue().size();
System.out.println(“当前排队任务数:” + queueSize);

int activeCount = tpe.getActiveCount();
System.out.println(“当前活动线程数:” + activeCount);

long completedTaskCount = tpe.getCompletedTaskCount();
System.out.println(“执行完成线程数:” + completedTaskCount);

long taskCount = tpe.getTaskCount();
System.out.println(“总线程数:” + taskCount);

Thread.sleep(3000);
}
}

}

 

程序每3秒打印一次线程池情况:

11111111111111111111111111111111111111111111111111
当前排队线程数:99950
当前活动线程数:50
执行完成线程数:0
总线程数:100000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
当前排队线程数:99849
当前活动线程数:50
执行完成线程数:127
总线程数:100000
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
当前排队线程数:99700
当前活动线程数:50
执行完成线程数:250
总线程数:100000
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
当前排队线程数:99550
当前活动线程数:50
执行完成线程数:400
总线程数:100000
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
当前排队线程数:99400
当前活动线程数:50
执行完成线程数:550
总线程数:100000
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
当前排队线程数:99250
当前活动线程数:50
执行完成线程数:700
总线程数:100000

。。。。。。

可以看到当前活动的线程数永远都是50, 为什么就没有突破?怎么没到100呢? 大家可以思考下,相信看了上面的描述,很容易就能理解了,DONE!

 

python 2中希望使用print时将\uxxxx的文字打印为中文

 python  python 2中希望使用print时将\uxxxx的文字打印为中文已关闭评论
5月 092020
 

在python 2里使用print打印含有\uxxx的中文字符时不能直接显示中文,可以使用下面的方式:

举例:

obj = [u’\u53c8\u6765\u5077\u5077\u770b\u6211′,u’\u7231\u6211\u4f60\u5c31\u544a\u8bc9\u6211′]

使用: print(repr(obj).decode(‘unicode-escape’))

 

obj=[‘又来偷偷看我’,’爱我你就告诉我’]

使用:print(repr(obj).decode(‘string-escape’))

 

python 3 没有这个问题

java中list及数组(含数组的数组)的打印输出

 java  java中list及数组(含数组的数组)的打印输出已关闭评论
11月 042015
 

java中list及数组(含数组的数组)的输出

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Hello {

public static void main(String[] args) {  
        List<String> list = new ArrayList<String>();  
        list.add(“tom”);  
        list.add(“jack”);  
        list.add(“rose”);  
        list.add(“simon”); 
        list.add(“john”);  
        System.out.println(“print list = ” + list);  
  
  
        String[] array = new String[] { “tom”, “jack”, “rose”, “simon” , “john”};  
        System.out.println(“print array = ” + array.toString());  
        System.out.println(“print array with  (Arrays.toString)= ” +  Arrays.toString(array));  
  
  
        String[] arr1 = new String[] { “tom1”, “jack1” };  
        String[] arr2 = new String[] { “rose1”, “simon1” };  
        String[][] arrayOfArray = new String[][] { arr1, arr2 };  
        System.out.println(“print arrayOfArray = ” + arrayOfArray);  
        System.out.println(“print arrayOfArray with  (Arrays.toString)= ” + Arrays.toString(arrayOfArray));  
        System.out.println(“print arrayOfArray with  (Arrays.deepToString)= ” + Arrays.deepToString(arrayOfArray));  

    }  

}

输出结果:

print list = [tom, jack, rose, simon, john]
print array = [Ljava.lang.String;@5f186fab
print array with  (Arrays.toString)= [tom, jack, rose, simon, john]
print arrayOfArray = [[Ljava.lang.String;@3d4b7453
print arrayOfArray with  (Arrays.toString)= [[Ljava.lang.String;@24c21495, [Ljava.lang.String;@41d5550d]
print arrayOfArray with  (Arrays.deepToString)= [[tom1, jack1], [rose1, simon1]]